1 ; RUN: opt -S -indvars < %s | FileCheck %s
3 ; This is not an IndVarSimplify bug, but the original symptom
6 define i32 @foo(i32 %a, i32 %b, i32 %c, i32* %sink) {
9 ; CHECK-NEXT: [[SHR:%.*]] = ashr i32 %neg3, -1
10 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[SHR]]
11 ; CHECK-NEXT: [[SHR1:%.*]] = ashr i32 [[SUB]], [[B:%.*]]
12 ; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[SHR1]], -1
13 ; CHECK-NEXT: store i32 [[NEG]], i32* %sink
16 %tobool2 = icmp eq i32 %a, 0
17 br i1 %tobool2, label %exit, label %preheader
20 %neg3 = phi i32 [ %c, %entry ], [ %neg, %for.end ]
24 %p = phi i32 [ %dec, %for ], [ 1, %preheader ]
25 %cmp = icmp sgt i32 %p, -1
26 %dec = add nsw i32 %p, -1
27 br i1 %cmp, label %for, label %for.end
30 %shr = ashr i32 %neg3, %p
31 %sub = sub nsw i32 0, %shr
32 %shr1 = ashr i32 %sub, %b
33 %neg = xor i32 %shr1, -1
34 store i32 %neg, i32* %sink
35 br i1 false, label %exit, label %preheader