Home | History | Annotate | Download | only in StructurizeCFG
      1 ; RUN: opt -S -o - -structurizecfg < %s | FileCheck %s
      2 
      3 ; CHECK-LABEL: @invert_branch_on_arg_inf_loop(
      4 ; CHECK: entry:
      5 ; CHECK: %arg.inv = xor i1 %arg, true
      6 ; CHECK: phi i1 [ false, %Flow1 ], [ %arg.inv, %entry ]
      7 define void @invert_branch_on_arg_inf_loop(i32 addrspace(1)* %out, i1 %arg) {
      8 entry:
      9   br i1 %arg, label %for.end, label %for.body
     10 
     11 for.body:                                         ; preds = %entry, %for.body
     12   store i32 999, i32 addrspace(1)* %out, align 4
     13   br label %for.body
     14 
     15 for.end:                                          ; preds = %Flow
     16   ret void
     17 }
     18 
     19 
     20 ; CHECK-LABEL: @invert_branch_on_arg_jump_into_loop(
     21 ; CHECK: entry:
     22 ; CHECK: %arg.inv = xor i1 %arg, true
     23 ; CHECK: Flow:
     24 ; CHECK: Flow1:
     25 define void @invert_branch_on_arg_jump_into_loop(i32 addrspace(1)* %out, i32 %n, i1 %arg) {
     26 entry:
     27   br label %for.body
     28 
     29 for.body:
     30   %i = phi i32 [0, %entry], [%i.inc, %end.loop]
     31   %ptr = getelementptr i32, i32 addrspace(1)* %out, i32 %i
     32   store i32 %i, i32 addrspace(1)* %ptr, align 4
     33   br i1 %arg, label %mid.loop, label %end.loop
     34 
     35 mid.loop:
     36   store i32 333, i32 addrspace(1)* %out, align 4
     37   br label %for.end
     38 
     39 end.loop:
     40   %i.inc = add i32 %i, 1
     41   %cmp = icmp ne i32 %i.inc, %n
     42   br i1 %cmp, label %for.body, label %for.end
     43 
     44 for.end:
     45   ret void
     46 }
     47 
     48