Home | History | Annotate | Download | only in ScalarEvolution
      1 ; RUN: opt -S -indvars < %s | FileCheck %s
      2 
      3 ; Check that SCEV does not assume sub nuw X Y == add nuw X, -Y
      4 define void @f(i32* %loc) {
      5 ; CHECK-LABEL: @f
      6  entry:
      7   br label %loop
      8 
      9  loop:
     10   %idx = phi i32 [ 6, %entry ], [ %idx.dec, %loop ]
     11   store i32 %idx, i32* %loc
     12   %idx.dec = sub nuw i32 %idx, 1
     13   %cond = icmp uge i32 %idx.dec, 5
     14   br i1 %cond, label %loop, label %exit
     15 ; CHECK-NOT: br i1 true, label %loop, label %exit
     16 
     17  exit:
     18   ret void
     19 }
     20 
     21 declare void @use_i1(i1)
     22 
     23 ; Check that SCEV does not assume sub nsw X Y == add nsw X, -Y
     24 define void @g(i32 %lim) {
     25 ; CHECK-LABEL: @g
     26  entry:
     27   br label %loop
     28 
     29  loop:
     30   %idx = phi i32 [ -1, %entry ], [ %idx.dec, %loop ]
     31   %t = icmp sgt i32 %idx, 0
     32 ; CHECK-NOT:   call void @use_i1(i1 false)
     33 ; CHECK: call void @use_i1(i1 %t)
     34   call void @use_i1(i1 %t)
     35   %idx.dec = sub nsw i32 %idx, -2147483648
     36   %cond = icmp eq i32 %idx.dec, %lim
     37   br i1 %cond, label %loop, label %exit
     38 
     39  exit:
     40   ret void
     41 }
     42