1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -analyze -scalar-evolution < %s | 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}<%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}<%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: --> %and 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: max backedge-taken count is 4294967295
20 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
21 ; CHECK-NEXT: Predicates:
22 ; CHECK: Loop %loop: Trip multiple is 1
25 %len.zext = zext i32 %len to i64
26 %len.sext = sext i32 %len to i64
29 %iv = phi i64 [0, %entry], [%iv.next, %loop]
30 %iv.next = add i64 %iv, 1
31 %cmp1 = icmp ult i64 %iv, %len.zext
32 %cmp2 = icmp ult i64 %iv, %len.sext
33 %and = and i1 %cmp1, %cmp2
34 br i1 %and, label %loop, label %exit
39 define void @ule_sext_x_zext_x(i32 %len) {
40 ; CHECK-LABEL: 'ule_sext_x_zext_x'
41 ; CHECK-NEXT: Classifying expressions for: @ule_sext_x_zext_x
42 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
43 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
44 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
45 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
46 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
47 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
48 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
49 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
50 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
51 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
52 ; CHECK-NEXT: Determining loop execution counts for: @ule_sext_x_zext_x
53 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
54 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
55 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
56 ; CHECK-NEXT: Predicates:
57 ; CHECK: Loop %loop: Trip multiple is 1
60 %len.zext = zext i32 %len to i64
61 %len.sext = sext i32 %len to i64
64 %iv = phi i64 [0, %entry], [%iv.next, %loop]
65 %iv.next = add i64 %iv, 1
66 %cmp1 = icmp ule i64 %len.zext, %len.sext
67 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
68 %cmp2 = icmp ult i64 %iv, %sel
69 br i1 %cmp2, label %loop, label %exit
74 define void @uge_sext_x_zext_x(i32 %len) {
75 ; CHECK-LABEL: 'uge_sext_x_zext_x'
76 ; CHECK-NEXT: Classifying expressions for: @uge_sext_x_zext_x
77 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
78 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
79 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
80 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
81 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
82 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
83 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
84 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
85 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
86 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
87 ; CHECK-NEXT: Determining loop execution counts for: @uge_sext_x_zext_x
88 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
89 ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
90 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
91 ; CHECK-NEXT: Predicates:
92 ; CHECK: Loop %loop: Trip multiple is 1
95 %len.zext = zext i32 %len to i64
96 %len.sext = sext i32 %len to i64
99 %iv = phi i64 [0, %entry], [%iv.next, %loop]
100 %iv.next = add i64 %iv, 1
101 %cmp1 = icmp uge i64 %len.zext, %len.sext
102 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
103 %cmp2 = icmp ult i64 %iv, %sel
104 br i1 %cmp2, label %loop, label %exit
109 define void @ult_sext_x_zext_x(i32 %len) {
110 ; CHECK-LABEL: 'ult_sext_x_zext_x'
111 ; CHECK-NEXT: Classifying expressions for: @ult_sext_x_zext_x
112 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
113 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
114 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
115 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
116 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
117 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
118 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
119 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
120 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
121 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
122 ; CHECK-NEXT: Determining loop execution counts for: @ult_sext_x_zext_x
123 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
124 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
125 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
126 ; CHECK-NEXT: Predicates:
127 ; CHECK: Loop %loop: Trip multiple is 1
130 %len.zext = zext i32 %len to i64
131 %len.sext = sext i32 %len to i64
134 %iv = phi i64 [0, %entry], [%iv.next, %loop]
135 %iv.next = add i64 %iv, 1
136 %cmp1 = icmp ult i64 %len.zext, %len.sext
137 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
138 %cmp2 = icmp ult i64 %iv, %umin
139 br i1 %cmp2, label %loop, label %exit
144 define void @ugt_sext_x_zext_x(i32 %len) {
145 ; CHECK-LABEL: 'ugt_sext_x_zext_x'
146 ; CHECK-NEXT: Classifying expressions for: @ugt_sext_x_zext_x
147 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
148 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
149 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
150 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
151 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
152 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
153 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
154 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
155 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
156 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
157 ; CHECK-NEXT: Determining loop execution counts for: @ugt_sext_x_zext_x
158 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
159 ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
160 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
161 ; CHECK-NEXT: Predicates:
162 ; CHECK: Loop %loop: Trip multiple is 1
165 %len.zext = zext i32 %len to i64
166 %len.sext = sext i32 %len to i64
169 %iv = phi i64 [0, %entry], [%iv.next, %loop]
170 %iv.next = add i64 %iv, 1
171 %cmp1 = icmp ugt i64 %len.zext, %len.sext
172 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
173 %cmp2 = icmp ult i64 %iv, %umax
174 br i1 %cmp2, label %loop, label %exit
179 define void @sle_sext_x_zext_x(i32 %len) {
180 ; CHECK-LABEL: 'sle_sext_x_zext_x'
181 ; CHECK-NEXT: Classifying expressions for: @sle_sext_x_zext_x
182 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
183 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
184 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
185 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
186 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
187 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
188 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
189 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
190 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
191 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
192 ; CHECK-NEXT: Determining loop execution counts for: @sle_sext_x_zext_x
193 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
194 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
195 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
196 ; CHECK-NEXT: Predicates:
197 ; CHECK: Loop %loop: Trip multiple is 1
200 %len.zext = zext i32 %len to i64
201 %len.sext = sext i32 %len to i64
204 %iv = phi i64 [0, %entry], [%iv.next, %loop]
205 %iv.next = add i64 %iv, 1
206 %cmp1 = icmp ule i64 %len.zext, %len.sext
207 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
208 %cmp2 = icmp ult i64 %iv, %sel
209 br i1 %cmp2, label %loop, label %exit
214 define void @sge_sext_x_zext_x(i32 %len) {
215 ; CHECK-LABEL: 'sge_sext_x_zext_x'
216 ; CHECK-NEXT: Classifying expressions for: @sge_sext_x_zext_x
217 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
218 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
219 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
220 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
221 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
222 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
223 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
224 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
225 ; CHECK-NEXT: %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
226 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
227 ; CHECK-NEXT: Determining loop execution counts for: @sge_sext_x_zext_x
228 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
229 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
230 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
231 ; CHECK-NEXT: Predicates:
232 ; CHECK: Loop %loop: Trip multiple is 1
235 %len.zext = zext i32 %len to i64
236 %len.sext = sext i32 %len to i64
239 %iv = phi i64 [0, %entry], [%iv.next, %loop]
240 %iv.next = add i64 %iv, 1
241 %cmp1 = icmp sge i64 %len.zext, %len.sext
242 %sel = select i1 %cmp1, i64 %len.zext, i64 %len.sext
243 %cmp2 = icmp ult i64 %iv, %sel
244 br i1 %cmp2, label %loop, label %exit
249 define void @slt_sext_x_zext_x(i32 %len) {
250 ; CHECK-LABEL: 'slt_sext_x_zext_x'
251 ; CHECK-NEXT: Classifying expressions for: @slt_sext_x_zext_x
252 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
253 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
254 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
255 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
256 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
257 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Computable }
258 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
259 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (sext i32 %len to i64))<nsw> LoopDispositions: { %loop: Computable }
260 ; CHECK-NEXT: %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
261 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648) Exits: (sext i32 %len to i64) LoopDispositions: { %loop: Invariant }
262 ; CHECK-NEXT: Determining loop execution counts for: @slt_sext_x_zext_x
263 ; CHECK-NEXT: Loop %loop: backedge-taken count is (sext i32 %len to i64)
264 ; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
265 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (sext i32 %len to i64)
266 ; CHECK-NEXT: Predicates:
267 ; CHECK: Loop %loop: Trip multiple is 1
270 %len.zext = zext i32 %len to i64
271 %len.sext = sext i32 %len to i64
274 %iv = phi i64 [0, %entry], [%iv.next, %loop]
275 %iv.next = add i64 %iv, 1
276 %cmp1 = icmp slt i64 %len.zext, %len.sext
277 %umin = select i1 %cmp1, i64 %len.zext, i64 %len.sext
278 %cmp2 = icmp ult i64 %iv, %umin
279 br i1 %cmp2, label %loop, label %exit
284 define void @sgt_sext_x_zext_x(i32 %len) {
285 ; CHECK-LABEL: 'sgt_sext_x_zext_x'
286 ; CHECK-NEXT: Classifying expressions for: @sgt_sext_x_zext_x
287 ; CHECK-NEXT: %len.zext = zext i32 %len to i64
288 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296)
289 ; CHECK-NEXT: %len.sext = sext i32 %len to i64
290 ; CHECK-NEXT: --> (sext i32 %len to i64) U: [-2147483648,2147483648) S: [-2147483648,2147483648)
291 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
292 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Computable }
293 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
294 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4294967297) S: [1,4294967297) Exits: (1 + (zext i32 %len to i64))<nuw><nsw> LoopDispositions: { %loop: Computable }
295 ; CHECK-NEXT: %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
296 ; CHECK-NEXT: --> (zext i32 %len to i64) U: [0,4294967296) S: [0,4294967296) Exits: (zext i32 %len to i64) LoopDispositions: { %loop: Invariant }
297 ; CHECK-NEXT: Determining loop execution counts for: @sgt_sext_x_zext_x
298 ; CHECK-NEXT: Loop %loop: backedge-taken count is (zext i32 %len to i64)
299 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4294967295
300 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (zext i32 %len to i64)
301 ; CHECK-NEXT: Predicates:
302 ; CHECK: Loop %loop: Trip multiple is 1
305 %len.zext = zext i32 %len to i64
306 %len.sext = sext i32 %len to i64
309 %iv = phi i64 [0, %entry], [%iv.next, %loop]
310 %iv.next = add i64 %iv, 1
311 %cmp1 = icmp sgt i64 %len.zext, %len.sext
312 %umax = select i1 %cmp1, i64 %len.zext, i64 %len.sext
313 %cmp2 = icmp ult i64 %iv, %umax
314 br i1 %cmp2, label %loop, label %exit