Home | History | Annotate | Download | only in IndVarSimplify
      1 ; RUN: opt -indvars -S < %s | FileCheck %s
      2 
      3 ; indvars should transform the phi node pair from the for-loop
      4 ; CHECK-LABEL: @main(
      5 ; CHECK: ret = phi i32 [ 0, %entry ], [ 0, {{.*}} ]
      6 
      7 @c = common global i32 0, align 4
      8 
      9 define i32 @main() #0 {
     10 entry:
     11   %0 = load i32* @c, align 4
     12   %tobool = icmp eq i32 %0, 0
     13   br i1 %tobool, label %for.body, label %exit
     14 
     15 for.body:
     16   %inc2 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
     17   %sub = add i32 %inc2, -1
     18   %cmp1 = icmp uge i32 %sub, %inc2
     19   %conv = zext i1 %cmp1 to i32
     20   br label %for.inc
     21 
     22 for.inc:
     23   %inc = add nsw i32 %inc2, 1
     24   %cmp = icmp slt i32 %inc, 5
     25   br i1 %cmp, label %for.body, label %exit
     26 
     27 exit:
     28   %ret = phi i32 [ 0, %entry ], [ %conv, %for.inc ]
     29   ret i32 %ret
     30 }
     31