1; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
2
3declare void @llvm.experimental.guard(i1, ...)
4declare void @llvm.assume(i1)
5
6define void @s_0(i32 %n, i1* %cond) {
7; CHECK-LABEL: Classifying expressions for: @s_0
8entry:
9  br label %loop
10
11loop:
12  %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
13  %iv.inc = add i32 %iv, 1
14  %iv.sext = sext i32 %iv to i64
15; CHECK:    %iv.sext = sext i32 %iv to i64
16; CHECK-NEXT:  -->  {0,+,1}<nuw><nsw><%loop>
17  %cmp = icmp slt i32 %iv, %n
18  call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
19  %c = load volatile i1, i1* %cond
20  br i1 %c, label %loop, label %leave
21
22leave:
23  ret void
24}
25
26define void @s_1(i1* %cond) {
27; CHECK-LABEL: Classifying expressions for: @s_1
28entry:
29  br label %loop
30
31loop:
32  %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
33  %iv.inc = add i32 %iv, 3
34  %iv.sext = sext i32 %iv to i64
35; CHECK:  %iv.sext = sext i32 %iv to i64
36; CHECK-NEXT:  -->  {0,+,3}<nuw><nsw><%loop>
37  %cmp = icmp slt i32 %iv, 10000
38  call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
39  %c = load volatile i1, i1* %cond
40  br i1 %c, label %loop, label %leave
41
42leave:
43  ret void
44}
45
46define void @s_2(i1* %cond) {
47; CHECK-LABEL: Classifying expressions for: @s_2
48entry:
49  br label %loop
50
51loop:
52  %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
53  %iv.inc = add i32 %iv, 3
54  %iv.sext = sext i32 %iv to i64
55  %cmp = icmp slt i32 %iv, 10000
56; CHECK:  %iv.sext = sext i32 %iv to i64
57; CHECK-NEXT:  -->  {0,+,3}<nuw><nsw><%loop>
58  call void @llvm.assume(i1 %cmp)
59  %c = load volatile i1, i1* %cond
60  br i1 %c, label %loop, label %leave
61
62leave:
63  ret void
64}
65
66define void @u_0(i32 %n, i1* %cond) {
67; CHECK-LABEL: Classifying expressions for: @u_0
68entry:
69  br label %loop
70
71loop:
72  %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
73  %iv.inc = add i32 %iv, 1
74  %iv.zext = zext i32 %iv to i64
75; CHECK:    %iv.zext = zext i32 %iv to i64
76; CHECK-NEXT:  -->  {0,+,1}<nuw><%loop>
77  %cmp = icmp ult i32 %iv, %n
78  call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
79  %c = load volatile i1, i1* %cond
80  br i1 %c, label %loop, label %leave
81
82leave:
83  ret void
84}
85
86define void @u_1(i1* %cond) {
87; CHECK-LABEL: Classifying expressions for: @u_1
88entry:
89  br label %loop
90
91loop:
92  %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
93  %iv.inc = add i32 %iv, 3
94  %iv.zext = zext i32 %iv to i64
95; CHECK:  %iv.zext = zext i32 %iv to i64
96; CHECK-NEXT:  -->  {0,+,3}<nuw><%loop>
97  %cmp = icmp ult i32 %iv, 10000
98  call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
99  %c = load volatile i1, i1* %cond
100  br i1 %c, label %loop, label %leave
101
102leave:
103  ret void
104}
105
106define void @u_2(i1* %cond) {
107; CHECK-LABEL: Classifying expressions for: @u_2
108entry:
109  br label %loop
110
111loop:
112  %iv = phi i32 [ 30000, %entry ], [ %iv.inc, %loop ]
113  %iv.inc = add i32 %iv, -2
114  %iv.zext = zext i32 %iv to i64
115  %cmp = icmp ugt i32 %iv.inc, -10000
116; CHECK:  %iv.zext = zext i32 %iv to i64
117; CHECK-NEXT:  -->  {30000,+,-2}<nw><%loop>
118  call void @llvm.assume(i1 %cmp)
119  %c = load volatile i1, i1* %cond
120  br i1 %c, label %loop, label %leave
121
122leave:
123  ret void
124}
125