1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
4 define void @umin_sext_x_zext_x(i32 %len) {
5 ; CHECK-LABEL: 'umin_sext_x_zext_x'
6 ; CHECK-NEXT: Classifying expressions for: @umin_sext_x_zext_x
7 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
8 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
9 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
10 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
11 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
12 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
13 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
14 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
15 ; CHECK-NEXT: %and = and i1 %cmp1, %cmp2
16 ; CHECK-NEXT: --> (%cmp1 umin %cmp2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
17 ; CHECK-NEXT: Determining loop execution counts for: @umin_sext_x_zext_x
18 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
19 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
20 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
21 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
24 %len.zext = zext i32 %len to i64
25 %len.sext = sext i32 %len to i64
28 %iv = phi i64 [0, %entry], [%iv.next, %loop]
29 %iv.next = add i64 %iv, 1
30 %cmp1 = icmp ult i64 %iv, %len.zext
31 %cmp2 = icmp ult i64 %iv, %len.sext
32 %and = and i1 %cmp1, %cmp2
33 br i1 %and, label %loop, label %exit
38 define void @ule_sext_x_zext_x(i32 %len) {
39 ; CHECK-LABEL: 'ule_sext_x_zext_x'
40 ; CHECK-NEXT: Classifying expressions for: @ule_sext_x_zext_x
41 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
42 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
43 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
44 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
45 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
46 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
47 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
48 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
49 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
50 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
51 ; CHECK-NEXT: Determining loop execution counts for: @ule_sext_x_zext_x
52 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
53 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
54 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
55 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
58 %len.zext = zext i32 %len to i64
59 %len.sext = sext i32 %len to i64
62 %iv = phi i64 [0, %entry], [%iv.next, %loop]
63 %iv.next = add i64 %iv, 1
64 %cmp1 = icmp ule i64 %len.zext, %len.sext
65 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
66 %cmp2 = icmp ult i64 %iv, %sel
67 br i1 %cmp2, label %loop, label %exit
72 define void @uge_sext_x_zext_x(i32 %len) {
73 ; CHECK-LABEL: 'uge_sext_x_zext_x'
74 ; CHECK-NEXT: Classifying expressions for: @uge_sext_x_zext_x
75 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
76 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
77 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
78 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
79 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
80 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
81 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
82 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
83 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
84 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
85 ; CHECK-NEXT: Determining loop execution counts for: @uge_sext_x_zext_x
86 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
87 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 -1
88 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
89 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
92 %len.zext = zext i32 %len to i64
93 %len.sext = sext i32 %len to i64
96 %iv = phi i64 [0, %entry], [%iv.next, %loop]
97 %iv.next = add i64 %iv, 1
98 %cmp1 = icmp uge i64 %len.zext, %len.sext
99 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
100 %cmp2 = icmp ult i64 %iv, %sel
101 br i1 %cmp2, label %loop, label %exit
106 define void @ult_sext_x_zext_x(i32 %len) {
107 ; CHECK-LABEL: 'ult_sext_x_zext_x'
108 ; CHECK-NEXT: Classifying expressions for: @ult_sext_x_zext_x
109 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
110 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
111 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
112 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
113 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
114 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
115 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
116 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
117 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
118 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
119 ; CHECK-NEXT: Determining loop execution counts for: @ult_sext_x_zext_x
120 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
121 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
122 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
123 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
126 %len.zext = zext i32 %len to i64
127 %len.sext = sext i32 %len to i64
130 %iv = phi i64 [0, %entry], [%iv.next, %loop]
131 %iv.next = add i64 %iv, 1
132 %cmp1 = icmp ult i64 %len.zext, %len.sext
133 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
134 %cmp2 = icmp ult i64 %iv, %umin
135 br i1 %cmp2, label %loop, label %exit
140 define void @ugt_sext_x_zext_x(i32 %len) {
141 ; CHECK-LABEL: 'ugt_sext_x_zext_x'
142 ; CHECK-NEXT: Classifying expressions for: @ugt_sext_x_zext_x
143 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
144 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
145 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
146 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
147 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
148 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
149 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
150 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
151 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
152 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
153 ; CHECK-NEXT: Determining loop execution counts for: @ugt_sext_x_zext_x
154 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
155 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 -1
156 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
157 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
160 %len.zext = zext i32 %len to i64
161 %len.sext = sext i32 %len to i64
164 %iv = phi i64 [0, %entry], [%iv.next, %loop]
165 %iv.next = add i64 %iv, 1
166 %cmp1 = icmp ugt i64 %len.zext, %len.sext
167 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
168 %cmp2 = icmp ult i64 %iv, %umax
169 br i1 %cmp2, label %loop, label %exit
174 define void @sle_sext_x_zext_x(i32 %len) {
175 ; CHECK-LABEL: 'sle_sext_x_zext_x'
176 ; CHECK-NEXT: Classifying expressions for: @sle_sext_x_zext_x
177 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
178 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
179 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
180 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
181 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
182 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
183 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
184 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
185 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
186 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
187 ; CHECK-NEXT: Determining loop execution counts for: @sle_sext_x_zext_x
188 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
189 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
190 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
191 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
194 %len.zext = zext i32 %len to i64
195 %len.sext = sext i32 %len to i64
198 %iv = phi i64 [0, %entry], [%iv.next, %loop]
199 %iv.next = add i64 %iv, 1
200 %cmp1 = icmp ule i64 %len.zext, %len.sext
201 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
202 %cmp2 = icmp ult i64 %iv, %sel
203 br i1 %cmp2, label %loop, label %exit
208 define void @sge_sext_x_zext_x(i32 %len) {
209 ; CHECK-LABEL: 'sge_sext_x_zext_x'
210 ; CHECK-NEXT: Classifying expressions for: @sge_sext_x_zext_x
211 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
212 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
213 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
214 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
215 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
216 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
217 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
218 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
219 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
220 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
221 ; CHECK-NEXT: Determining loop execution counts for: @sge_sext_x_zext_x
222 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
223 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
224 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
225 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
228 %len.zext = zext i32 %len to i64
229 %len.sext = sext i32 %len to i64
232 %iv = phi i64 [0, %entry], [%iv.next, %loop]
233 %iv.next = add i64 %iv, 1
234 %cmp1 = icmp sge i64 %len.zext, %len.sext
235 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
236 %cmp2 = icmp ult i64 %iv, %sel
237 br i1 %cmp2, label %loop, label %exit
242 define void @slt_sext_x_zext_x(i32 %len) {
243 ; CHECK-LABEL: 'slt_sext_x_zext_x'
244 ; CHECK-NEXT: Classifying expressions for: @slt_sext_x_zext_x
245 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
246 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
247 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
248 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
249 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
250 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
251 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
252 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
253 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
254 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
255 ; CHECK-NEXT: Determining loop execution counts for: @slt_sext_x_zext_x
256 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
257 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 -1
258 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
259 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
262 %len.zext = zext i32 %len to i64
263 %len.sext = sext i32 %len to i64
266 %iv = phi i64 [0, %entry], [%iv.next, %loop]
267 %iv.next = add i64 %iv, 1
268 %cmp1 = icmp slt i64 %len.zext, %len.sext
269 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
270 %cmp2 = icmp ult i64 %iv, %umin
271 br i1 %cmp2, label %loop, label %exit
276 define void @sgt_sext_x_zext_x(i32 %len) {
277 ; CHECK-LABEL: 'sgt_sext_x_zext_x'
278 ; CHECK-NEXT: Classifying expressions for: @sgt_sext_x_zext_x
279 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
280 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
281 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
282 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
283 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
284 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
285 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
286 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
287 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
288 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
289 ; CHECK-NEXT: Determining loop execution counts for: @sgt_sext_x_zext_x
290 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
291 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4294967295
292 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
293 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
296 %len.zext = zext i32 %len to i64
297 %len.sext = sext i32 %len to i64
300 %iv = phi i64 [0, %entry], [%iv.next, %loop]
301 %iv.next = add i64 %iv, 1
302 %cmp1 = icmp sgt i64 %len.zext, %len.sext
303 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
304 %cmp2 = icmp ult i64 %iv, %umax
305 br i1 %cmp2, label %loop, label %exit