Home | History | Annotate | Download | only in IndVarSimplify
      1 ;RUN: opt -S %s -indvars | FileCheck %s
      2 
      3 ; CHECK-LABEL-LABEL: @foo(
      4 ; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
      5 ; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
      6 define void @foo() #0 {
      7 entry:
      8   br label %for.body
      9 
     10 for.body:                                         ; preds = %entry, %for.body
     11   %i.01 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
     12   %conv2 = sext i16 %i.01 to i32
     13   call void @bar(i32 %conv2) #1
     14   %inc = add i16 %i.01, 1
     15   %cmp = icmp slt i16 %inc, 512
     16   br i1 %cmp, label %for.body, label %for.end
     17 
     18 for.end:                                          ; preds = %for.body
     19   ret void
     20 }
     21 
     22 ; Check that post-incrementing the backedge taken count does not overflow.
     23 ; CHECK-LABEL-LABEL: @postinc(
     24 ; CHECK: icmp eq i32 %indvars.iv.next, 256
     25 define i32 @postinc() #0 {
     26 entry:
     27   br label %do.body
     28 
     29 do.body:                                          ; preds = %do.body, %entry
     30   %first.0 = phi i8 [ 0, %entry ], [ %inc, %do.body ]
     31   %conv = zext i8 %first.0 to i32
     32   call void  @bar(i32 %conv) #1
     33   %inc = add i8 %first.0, 1
     34   %cmp = icmp eq i8 %first.0, -1
     35   br i1 %cmp, label %do.end, label %do.body
     36 
     37 do.end:                                           ; preds = %do.body
     38   ret i32 0
     39 }
     40 
     41 declare void @bar(i32)
     42 
     43 attributes #0 = { nounwind uwtable }
     44 attributes #1 = { nounwind }
     45