1 ; RUN: opt -S -indvars < %s | FileCheck %s
3 ; Check that SCEV does not assume sub nuw X Y == add nuw X, -Y
4 define void @f(i32* %loc) {
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
21 declare void @use_i1(i1)
23 ; Check that SCEV does not assume sub nsw X Y == add nsw X, -Y
24 define void @g(i32 %lim) {
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