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 4294967295
20 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
21 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
22 ; CHECK-NEXT: Predicates:
23 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
26 %len.zext = zext i32 %len to i64
27 %len.sext = sext i32 %len to i64
30 %iv = phi i64 [0, %entry], [%iv.next, %loop]
31 %iv.next = add i64 %iv, 1
32 %cmp1 = icmp ult i64 %iv, %len.zext
33 %cmp2 = icmp ult i64 %iv, %len.sext
34 %and = and i1 %cmp1, %cmp2
35 br i1 %and, label %loop, label %exit
40 define void @ule_sext_x_zext_x(i32 %len) {
41 ; CHECK-LABEL: 'ule_sext_x_zext_x'
42 ; CHECK-NEXT: Classifying expressions for: @ule_sext_x_zext_x
43 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
44 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
45 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
46 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
47 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
48 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
49 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
50 ; 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 }
51 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
52 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
53 ; CHECK-NEXT: Determining loop execution counts for: @ule_sext_x_zext_x
54 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
55 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4294967295
56 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
57 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
58 ; CHECK-NEXT: Predicates:
59 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
62 %len.zext = zext i32 %len to i64
63 %len.sext = sext i32 %len to i64
66 %iv = phi i64 [0, %entry], [%iv.next, %loop]
67 %iv.next = add i64 %iv, 1
68 %cmp1 = icmp ule i64 %len.zext, %len.sext
69 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
70 %cmp2 = icmp ult i64 %iv, %sel
71 br i1 %cmp2, label %loop, label %exit
76 define void @uge_sext_x_zext_x(i32 %len) {
77 ; CHECK-LABEL: 'uge_sext_x_zext_x'
78 ; CHECK-NEXT: Classifying expressions for: @uge_sext_x_zext_x
79 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
80 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
81 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
82 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
83 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
84 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
85 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
86 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
87 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
88 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
89 ; CHECK-NEXT: Determining loop execution counts for: @uge_sext_x_zext_x
90 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
91 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
92 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
93 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
94 ; CHECK-NEXT: Predicates:
95 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
98 %len.zext = zext i32 %len to i64
99 %len.sext = sext i32 %len to i64
102 %iv = phi i64 [0, %entry], [%iv.next, %loop]
103 %iv.next = add i64 %iv, 1
104 %cmp1 = icmp uge i64 %len.zext, %len.sext
105 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
106 %cmp2 = icmp ult i64 %iv, %sel
107 br i1 %cmp2, label %loop, label %exit
112 define void @ult_sext_x_zext_x(i32 %len) {
113 ; CHECK-LABEL: 'ult_sext_x_zext_x'
114 ; CHECK-NEXT: Classifying expressions for: @ult_sext_x_zext_x
115 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
116 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
117 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
118 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
119 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
120 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
121 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
122 ; 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 }
123 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
124 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
125 ; CHECK-NEXT: Determining loop execution counts for: @ult_sext_x_zext_x
126 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
127 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4294967295
128 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
129 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
130 ; CHECK-NEXT: Predicates:
131 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
134 %len.zext = zext i32 %len to i64
135 %len.sext = sext i32 %len to i64
138 %iv = phi i64 [0, %entry], [%iv.next, %loop]
139 %iv.next = add i64 %iv, 1
140 %cmp1 = icmp ult i64 %len.zext, %len.sext
141 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
142 %cmp2 = icmp ult i64 %iv, %umin
143 br i1 %cmp2, label %loop, label %exit
148 define void @ugt_sext_x_zext_x(i32 %len) {
149 ; CHECK-LABEL: 'ugt_sext_x_zext_x'
150 ; CHECK-NEXT: Classifying expressions for: @ugt_sext_x_zext_x
151 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
152 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
153 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
154 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
155 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
156 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
157 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
158 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
159 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
160 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
161 ; CHECK-NEXT: Determining loop execution counts for: @ugt_sext_x_zext_x
162 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
163 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
164 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
165 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
166 ; CHECK-NEXT: Predicates:
167 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
170 %len.zext = zext i32 %len to i64
171 %len.sext = sext i32 %len to i64
174 %iv = phi i64 [0, %entry], [%iv.next, %loop]
175 %iv.next = add i64 %iv, 1
176 %cmp1 = icmp ugt i64 %len.zext, %len.sext
177 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
178 %cmp2 = icmp ult i64 %iv, %umax
179 br i1 %cmp2, label %loop, label %exit
184 define void @sle_sext_x_zext_x(i32 %len) {
185 ; CHECK-LABEL: 'sle_sext_x_zext_x'
186 ; CHECK-NEXT: Classifying expressions for: @sle_sext_x_zext_x
187 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
188 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
189 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
190 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
191 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
192 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
193 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
194 ; 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 }
195 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
196 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
197 ; CHECK-NEXT: Determining loop execution counts for: @sle_sext_x_zext_x
198 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
199 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4294967295
200 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
201 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
202 ; CHECK-NEXT: Predicates:
203 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
206 %len.zext = zext i32 %len to i64
207 %len.sext = sext i32 %len to i64
210 %iv = phi i64 [0, %entry], [%iv.next, %loop]
211 %iv.next = add i64 %iv, 1
212 %cmp1 = icmp ule i64 %len.zext, %len.sext
213 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
214 %cmp2 = icmp ult i64 %iv, %sel
215 br i1 %cmp2, label %loop, label %exit
220 define void @sge_sext_x_zext_x(i32 %len) {
221 ; CHECK-LABEL: 'sge_sext_x_zext_x'
222 ; CHECK-NEXT: Classifying expressions for: @sge_sext_x_zext_x
223 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
224 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
225 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
226 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
227 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
228 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
229 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
230 ; 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 }
231 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
232 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
233 ; CHECK-NEXT: Determining loop execution counts for: @sge_sext_x_zext_x
234 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
235 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4294967295
236 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
237 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
238 ; CHECK-NEXT: Predicates:
239 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
242 %len.zext = zext i32 %len to i64
243 %len.sext = sext i32 %len to i64
246 %iv = phi i64 [0, %entry], [%iv.next, %loop]
247 %iv.next = add i64 %iv, 1
248 %cmp1 = icmp sge i64 %len.zext, %len.sext
249 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
250 %cmp2 = icmp ult i64 %iv, %sel
251 br i1 %cmp2, label %loop, label %exit
256 define void @slt_sext_x_zext_x(i32 %len) {
257 ; CHECK-LABEL: 'slt_sext_x_zext_x'
258 ; CHECK-NEXT: Classifying expressions for: @slt_sext_x_zext_x
259 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
260 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
261 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
262 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
263 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
264 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
265 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
266 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
267 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
268 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
269 ; CHECK-NEXT: Determining loop execution counts for: @slt_sext_x_zext_x
270 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
271 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
272 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (sext i32 %len to i64)
273 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
274 ; CHECK-NEXT: Predicates:
275 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
278 %len.zext = zext i32 %len to i64
279 %len.sext = sext i32 %len to i64
282 %iv = phi i64 [0, %entry], [%iv.next, %loop]
283 %iv.next = add i64 %iv, 1
284 %cmp1 = icmp slt i64 %len.zext, %len.sext
285 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
286 %cmp2 = icmp ult i64 %iv, %umin
287 br i1 %cmp2, label %loop, label %exit
292 define void @sgt_sext_x_zext_x(i32 %len) {
293 ; CHECK-LABEL: 'sgt_sext_x_zext_x'
294 ; CHECK-NEXT: Classifying expressions for: @sgt_sext_x_zext_x
295 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
296 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
297 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
298 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
299 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
300 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
301 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
302 ; 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 }
303 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
304 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
305 ; CHECK-NEXT: Determining loop execution counts for: @sgt_sext_x_zext_x
306 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
307 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4294967295
308 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (zext i32 %len to i64)
309 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
310 ; CHECK-NEXT: Predicates:
311 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
314 %len.zext = zext i32 %len to i64
315 %len.sext = sext i32 %len to i64
318 %iv = phi i64 [0, %entry], [%iv.next, %loop]
319 %iv.next = add i64 %iv, 1
320 %cmp1 = icmp sgt i64 %len.zext, %len.sext
321 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
322 %cmp2 = icmp ult i64 %iv, %umax
323 br i1 %cmp2, label %loop, label %exit