1; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
2
3define void @f(i1* %condition) {
4; CHECK-LABEL: Classifying expressions for: @f
5 entry:
6  br label %loop
7
8 loop:
9  %idx = phi i32 [ 0, %entry ], [ %idx.inc, %loop ]
10  %idx.inc = add nsw i32 %idx, 1
11
12  %idx.inc2 = add i32 %idx.inc, 1
13  %idx.inc2.zext = zext i32 %idx.inc2 to i64
14
15; CHECK: %idx.inc2.zext = zext i32 %idx.inc2 to i64
16; CHECK-NEXT: -->  {2,+,1}<nuw><%loop>
17
18  %c = load volatile i1, i1* %condition
19  br i1 %c, label %loop, label %exit
20
21 exit:
22  ret void
23}
24
25define void @g(i1* %condition) {
26; CHECK-LABEL: Classifying expressions for: @g
27 entry:
28  br label %loop
29
30 loop:
31  %idx = phi i32 [ 0, %entry ], [ %idx.inc, %loop ]
32  %idx.inc = add nsw i32 %idx, 3
33
34  %idx.inc2 = add i32 %idx.inc, -1
35  %idx.inc2.sext = sext i32 %idx.inc2 to i64
36; CHECK: %idx.inc2.sext = sext i32 %idx.inc2 to i64
37; CHECK-NEXT: -->  {2,+,3}<nuw><nsw><%loop>
38
39  %cond.gep = getelementptr inbounds i1, i1* %condition, i32 %idx.inc
40  %c = load volatile i1, i1* %cond.gep
41  br i1 %c, label %loop, label %exit
42
43 exit:
44  ret void
45}
46