[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / Analysis / ScalarEvolution / exit-count-select-safe.ll
blob3b25bb94b712471f26669bc4b25cc6f7cf1c9560
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 i32 @logical_and_2ops(i32 %n, i32 %m) {
5 ; CHECK-LABEL: 'logical_and_2ops'
6 ; CHECK-NEXT:  Classifying expressions for: @logical_and_2ops
7 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
8 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
9 ; CHECK-NEXT:    %i.next = add i32 %i, 1
10 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
11 ; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
12 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
13 ; CHECK-NEXT:  Determining loop execution counts for: @logical_and_2ops
14 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
15 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
16 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
17 ; CHECK-NEXT:   Predicates:
18 ; CHECK:       Loop %loop: Trip multiple is 1
20 entry:
21   br label %loop
22 loop:
23   %i = phi i32 [0, %entry], [%i.next, %loop]
24   %i.next = add i32 %i, 1
25   %cond_p0 = icmp ult i32 %i, %n
26   %cond_p1 = icmp ult i32 %i, %m
27   %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
28   br i1 %cond, label %loop, label %exit
29 exit:
30   ret i32 %i
33 define i32 @logical_or_2ops(i32 %n, i32 %m) {
34 ; CHECK-LABEL: 'logical_or_2ops'
35 ; CHECK-NEXT:  Classifying expressions for: @logical_or_2ops
36 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
37 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
38 ; CHECK-NEXT:    %i.next = add i32 %i, 1
39 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
40 ; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
41 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
42 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_2ops
43 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
44 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
45 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
46 ; CHECK-NEXT:   Predicates:
47 ; CHECK:       Loop %loop: Trip multiple is 1
49 entry:
50   br label %loop
51 loop:
52   %i = phi i32 [0, %entry], [%i.next, %loop]
53   %i.next = add i32 %i, 1
54   %cond_p0 = icmp uge i32 %i, %n
55   %cond_p1 = icmp uge i32 %i, %m
56   %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
57   br i1 %cond, label %exit, label %loop
58 exit:
59   ret i32 %i
62 define i32 @logical_and_3ops(i32 %n, i32 %m, i32 %k) {
63 ; CHECK-LABEL: 'logical_and_3ops'
64 ; CHECK-NEXT:  Classifying expressions for: @logical_and_3ops
65 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
66 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
67 ; CHECK-NEXT:    %i.next = add i32 %i, 1
68 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
69 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
70 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
71 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
72 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
73 ; CHECK-NEXT:  Determining loop execution counts for: @logical_and_3ops
74 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
75 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
76 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
77 ; CHECK-NEXT:   Predicates:
78 ; CHECK:       Loop %loop: Trip multiple is 1
80 entry:
81   br label %loop
82 loop:
83   %i = phi i32 [0, %entry], [%i.next, %loop]
84   %i.next = add i32 %i, 1
85   %cond_p0 = icmp ult i32 %i, %n
86   %cond_p1 = icmp ult i32 %i, %m
87   %cond_p2 = icmp ult i32 %i, %k
88   %cond_p3 = select i1 %cond_p0, i1 %cond_p1, i1 false
89   %cond = select i1 %cond_p3, i1 %cond_p2, i1 false
90   br i1 %cond, label %loop, label %exit
91 exit:
92   ret i32 %i
95 define i32 @logical_or_3ops(i32 %n, i32 %m, i32 %k) {
96 ; CHECK-LABEL: 'logical_or_3ops'
97 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops
98 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
99 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
100 ; CHECK-NEXT:    %i.next = add i32 %i, 1
101 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
102 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
103 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
104 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
105 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
106 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops
107 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
108 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
109 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
110 ; CHECK-NEXT:   Predicates:
111 ; CHECK:       Loop %loop: Trip multiple is 1
113 entry:
114   br label %loop
115 loop:
116   %i = phi i32 [0, %entry], [%i.next, %loop]
117   %i.next = add i32 %i, 1
118   %cond_p0 = icmp uge i32 %i, %n
119   %cond_p1 = icmp uge i32 %i, %m
120   %cond_p2 = icmp uge i32 %i, %k
121   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
122   %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
123   br i1 %cond, label %exit, label %loop
124 exit:
125   ret i32 %i
128 define i32 @logical_or_3ops_duplicate(i32 %n, i32 %m, i32 %k) {
129 ; CHECK-LABEL: 'logical_or_3ops_duplicate'
130 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_duplicate
131 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
132 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m umin_seq %k) LoopDispositions: { %loop: Computable }
133 ; CHECK-NEXT:    %i.next = add i32 %i, 1
134 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m umin_seq %k)) LoopDispositions: { %loop: Computable }
135 ; CHECK-NEXT:    %cond_p4 = select i1 %cond_p0, i1 true, i1 %cond_p1
136 ; CHECK-NEXT:    --> %cond_p4 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
137 ; CHECK-NEXT:    %cond_p5 = select i1 %cond_p4, i1 true, i1 %cond_p2
138 ; CHECK-NEXT:    --> %cond_p5 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
139 ; CHECK-NEXT:    %cond = select i1 %cond_p5, i1 true, i1 %cond_p3
140 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
141 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_duplicate
142 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m umin_seq %k)
143 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
144 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m umin_seq %k)
145 ; CHECK-NEXT:   Predicates:
146 ; CHECK:       Loop %loop: Trip multiple is 1
148 entry:
149   br label %loop
150 loop:
151   %i = phi i32 [0, %entry], [%i.next, %loop]
152   %i.next = add i32 %i, 1
153   %cond_p0 = icmp uge i32 %i, %n
154   %cond_p1 = icmp uge i32 %i, %m
155   %cond_p2 = icmp uge i32 %i, %n
156   %cond_p3 = icmp uge i32 %i, %k
157   %cond_p4 = select i1 %cond_p0, i1 true, i1 %cond_p1
158   %cond_p5 = select i1 %cond_p4, i1 true, i1 %cond_p2
159   %cond = select i1 %cond_p5, i1 true, i1 %cond_p3
160   br i1 %cond, label %exit, label %loop
161 exit:
162   ret i32 %i
165 define i32 @logical_or_3ops_redundant_uminseq_operand(i32 %n, i32 %m, i32 %k) {
166 ; CHECK-LABEL: 'logical_or_3ops_redundant_uminseq_operand'
167 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_uminseq_operand
168 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
169 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k) LoopDispositions: { %loop: Computable }
170 ; CHECK-NEXT:    %i.next = add i32 %i, 1
171 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k)) LoopDispositions: { %loop: Computable }
172 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
173 ; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
174 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
175 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
176 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
177 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
178 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_uminseq_operand
179 ; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k)
180 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
181 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k)
182 ; CHECK-NEXT:   Predicates:
183 ; CHECK:       Loop %loop: Trip multiple is 1
185 entry:
186   br label %loop
187 loop:
188   %i = phi i32 [0, %entry], [%i.next, %loop]
189   %i.next = add i32 %i, 1
190   %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
191   %cond_p0 = icmp uge i32 %i, %umin
192   %cond_p1 = icmp uge i32 %i, %n
193   %cond_p2 = icmp uge i32 %i, %k
194   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
195   %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
196   br i1 %cond, label %exit, label %loop
197 exit:
198   ret i32 %i
201 define i32 @logical_or_3ops_redundant_umin_operand(i32 %n, i32 %m, i32 %k) {
202 ; CHECK-LABEL: 'logical_or_3ops_redundant_umin_operand'
203 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_redundant_umin_operand
204 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
205 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %k umin_seq %m) LoopDispositions: { %loop: Computable }
206 ; CHECK-NEXT:    %i.next = add i32 %i, 1
207 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %k umin_seq %m)) LoopDispositions: { %loop: Computable }
208 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
209 ; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
210 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
211 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
212 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
213 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
214 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_redundant_umin_operand
215 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %k umin_seq %m)
216 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
217 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %k umin_seq %m)
218 ; CHECK-NEXT:   Predicates:
219 ; CHECK:       Loop %loop: Trip multiple is 1
221 entry:
222   br label %loop
223 loop:
224   %i = phi i32 [0, %entry], [%i.next, %loop]
225   %i.next = add i32 %i, 1
226   %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
227   %cond_p0 = icmp uge i32 %i, %n
228   %cond_p1 = icmp uge i32 %i, %k
229   %cond_p2 = icmp uge i32 %i, %umin
230   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
231   %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
232   br i1 %cond, label %exit, label %loop
233 exit:
234   ret i32 %i
237 define i32 @logical_or_4ops_redundant_operand_across_umins(i32 %n, i32 %m, i32 %k, i32 %q) {
238 ; CHECK-LABEL: 'logical_or_4ops_redundant_operand_across_umins'
239 ; CHECK-NEXT:  Classifying expressions for: @logical_or_4ops_redundant_operand_across_umins
240 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
241 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k umin_seq %q) LoopDispositions: { %loop: Computable }
242 ; CHECK-NEXT:    %i.next = add i32 %i, 1
243 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k umin_seq %q)) LoopDispositions: { %loop: Computable }
244 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
245 ; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
246 ; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
247 ; CHECK-NEXT:    --> (%n umin %q) U: full-set S: full-set Exits: (%n umin %q) LoopDispositions: { %loop: Invariant }
248 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
249 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
250 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
251 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
252 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_4ops_redundant_operand_across_umins
253 ; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k umin_seq %q)
254 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
255 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k umin_seq %q)
256 ; CHECK-NEXT:   Predicates:
257 ; CHECK:       Loop %loop: Trip multiple is 1
259 entry:
260   br label %loop
261 loop:
262   %i = phi i32 [0, %entry], [%i.next, %loop]
263   %i.next = add i32 %i, 1
264   %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
265   %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %q)
266   %cond_p0 = icmp uge i32 %i, %umin
267   %cond_p1 = icmp uge i32 %i, %k
268   %cond_p2 = icmp uge i32 %i, %umin2
269   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
270   %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
271   br i1 %cond, label %exit, label %loop
272 exit:
273   ret i32 %i
276 define i32 @logical_or_3ops_operand_wise_redundant_umin(i32 %n, i32 %m, i32 %k) {
277 ; CHECK-LABEL: 'logical_or_3ops_operand_wise_redundant_umin'
278 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_operand_wise_redundant_umin
279 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
280 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: ((%n umin %m) umin_seq %k) LoopDispositions: { %loop: Computable }
281 ; CHECK-NEXT:    %i.next = add i32 %i, 1
282 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + ((%n umin %m) umin_seq %k)) LoopDispositions: { %loop: Computable }
283 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
284 ; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
285 ; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %k)
286 ; CHECK-NEXT:    --> (%n umin %k) U: full-set S: full-set Exits: (%n umin %k) LoopDispositions: { %loop: Invariant }
287 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
288 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
289 ; CHECK-NEXT:    %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
290 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
291 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_operand_wise_redundant_umin
292 ; CHECK-NEXT:  Loop %loop: backedge-taken count is ((%n umin %m) umin_seq %k)
293 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
294 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is ((%n umin %m) umin_seq %k)
295 ; CHECK-NEXT:   Predicates:
296 ; CHECK:       Loop %loop: Trip multiple is 1
298 entry:
299   br label %loop
300 loop:
301   %i = phi i32 [0, %entry], [%i.next, %loop]
302   %i.next = add i32 %i, 1
303   %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
304   %umin2 = call i32 @llvm.umin.i32(i32 %n, i32 %k)
305   %cond_p0 = icmp uge i32 %i, %umin
306   %cond_p1 = icmp uge i32 %i, %k
307   %cond_p2 = icmp uge i32 %i, %umin2
308   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
309   %cond = select i1 %cond_p3, i1 true, i1 %cond_p2
310   br i1 %cond, label %exit, label %loop
311 exit:
312   ret i32 %i
315 define i32 @logical_or_3ops_partially_redundant_umin(i32 %n, i32 %m, i32 %k) {
316 ; CHECK-LABEL: 'logical_or_3ops_partially_redundant_umin'
317 ; CHECK-NEXT:  Classifying expressions for: @logical_or_3ops_partially_redundant_umin
318 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
319 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq (%m umin %k)) LoopDispositions: { %loop: Computable }
320 ; CHECK-NEXT:    %i.next = add i32 %i, 1
321 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq (%m umin %k))) LoopDispositions: { %loop: Computable }
322 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
323 ; CHECK-NEXT:    --> (%n umin %m) U: full-set S: full-set Exits: (%n umin %m) LoopDispositions: { %loop: Invariant }
324 ; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %k)
325 ; CHECK-NEXT:    --> (%n umin %m umin %k) U: full-set S: full-set Exits: (%n umin %m umin %k) LoopDispositions: { %loop: Invariant }
326 ; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
327 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
328 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_3ops_partially_redundant_umin
329 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq (%m umin %k))
330 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
331 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq (%m umin %k))
332 ; CHECK-NEXT:   Predicates:
333 ; CHECK:       Loop %loop: Trip multiple is 1
335 entry:
336   br label %loop
337 loop:
338   %i = phi i32 [0, %entry], [%i.next, %loop]
339   %i.next = add i32 %i, 1
340   %umin = call i32 @llvm.umin.i32(i32 %n, i32 %m)
341   %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %k)
342   %cond_p0 = icmp uge i32 %i, %n
343   %cond_p1 = icmp uge i32 %i, %umin2
344   %cond = select i1 %cond_p0, i1 true, i1 %cond_p1
345   br i1 %cond, label %exit, label %loop
346 exit:
347   ret i32 %i
350 define i32 @logical_or_5ops_redundant_opearand_of_inner_uminseq(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
351 ; CHECK-LABEL: 'logical_or_5ops_redundant_opearand_of_inner_uminseq'
352 ; CHECK-NEXT:  Classifying expressions for: @logical_or_5ops_redundant_opearand_of_inner_uminseq
353 ; CHECK-NEXT:    %first.i = phi i32 [ 0, %entry ], [ %first.i.next, %first.loop ]
354 ; CHECK-NEXT:    --> {0,+,1}<%first.loop> U: full-set S: full-set Exits: (%e umin_seq %d umin_seq %a) LoopDispositions: { %first.loop: Computable }
355 ; CHECK-NEXT:    %first.i.next = add i32 %first.i, 1
356 ; CHECK-NEXT:    --> {1,+,1}<%first.loop> U: full-set S: full-set Exits: (1 + (%e umin_seq %d umin_seq %a)) LoopDispositions: { %first.loop: Computable }
357 ; CHECK-NEXT:    %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
358 ; CHECK-NEXT:    --> %cond_p3 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %first.loop: Variant }
359 ; CHECK-NEXT:    %cond_p4 = select i1 %cond_p3, i1 true, i1 %cond_p2
360 ; CHECK-NEXT:    --> %cond_p4 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %first.loop: Variant }
361 ; CHECK-NEXT:    %i = phi i32 [ 0, %first.loop.exit ], [ %i.next, %loop ]
362 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c)) LoopDispositions: { %loop: Computable }
363 ; CHECK-NEXT:    %i.next = add i32 %i, 1
364 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))) LoopDispositions: { %loop: Computable }
365 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %c, i32 %d)
366 ; CHECK-NEXT:    --> (%c umin %d) U: full-set S: full-set Exits: (%c umin %d) LoopDispositions: { %loop: Invariant }
367 ; CHECK-NEXT:    %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %first.i)
368 ; CHECK-NEXT:    --> ({0,+,1}<%first.loop> umin %c umin %d) U: full-set S: full-set --> ((%e umin_seq %d umin_seq %a) umin %c umin %d) U: full-set S: full-set Exits: ((%e umin_seq %d umin_seq %a) umin %c umin %d) LoopDispositions: { %loop: Invariant }
369 ; CHECK-NEXT:    %cond_p8 = select i1 %cond_p5, i1 true, i1 %cond_p6
370 ; CHECK-NEXT:    --> %cond_p8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
371 ; CHECK-NEXT:    %cond = select i1 %cond_p8, i1 true, i1 %cond_p7
372 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
373 ; CHECK-NEXT:  Determining loop execution counts for: @logical_or_5ops_redundant_opearand_of_inner_uminseq
374 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))
375 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
376 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%a umin_seq %b umin_seq ((%e umin_seq %d) umin %c))
377 ; CHECK-NEXT:   Predicates:
378 ; CHECK:       Loop %loop: Trip multiple is 1
379 ; CHECK-NEXT:  Loop %first.loop: backedge-taken count is (%e umin_seq %d umin_seq %a)
380 ; CHECK-NEXT:  Loop %first.loop: max backedge-taken count is -1
381 ; CHECK-NEXT:  Loop %first.loop: Predicated backedge-taken count is (%e umin_seq %d umin_seq %a)
382 ; CHECK-NEXT:   Predicates:
383 ; CHECK:       Loop %first.loop: Trip multiple is 1
385 entry:
386   br label %first.loop
387 first.loop:
388   %first.i = phi i32 [0, %entry], [%first.i.next, %first.loop]
389   %first.i.next = add i32 %first.i, 1
390   %cond_p0 = icmp uge i32 %first.i, %e
391   %cond_p1 = icmp uge i32 %first.i, %d
392   %cond_p2 = icmp uge i32 %first.i, %a
393   %cond_p3 = select i1 %cond_p0, i1 true, i1 %cond_p1
394   %cond_p4 = select i1 %cond_p3, i1 true, i1 %cond_p2
395   br i1 %cond_p4, label %first.loop.exit, label %first.loop
396 first.loop.exit:
397   br label %loop
398 loop:
399   %i = phi i32 [0, %first.loop.exit], [%i.next, %loop]
400   %i.next = add i32 %i, 1
401   %umin = call i32 @llvm.umin.i32(i32 %c, i32 %d)
402   %umin2 = call i32 @llvm.umin.i32(i32 %umin, i32 %first.i)
403   %cond_p5 = icmp uge i32 %i, %a
404   %cond_p6 = icmp uge i32 %i, %b
405   %cond_p7 = icmp uge i32 %i, %umin2
406   %cond_p8 = select i1 %cond_p5, i1 true, i1 %cond_p6
407   %cond = select i1 %cond_p8, i1 true, i1 %cond_p7
408   br i1 %cond, label %exit, label %loop
409 exit:
410   ret i32 %i
413 define i32 @logical_and_2ops_and_constant(i32 %n, i32 %m, i32 %k) {
414 ; CHECK-LABEL: 'logical_and_2ops_and_constant'
415 ; CHECK-NEXT:  Classifying expressions for: @logical_and_2ops_and_constant
416 ; CHECK-NEXT:    %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
417 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: [0,43) S: [0,43) Exits: (42 umin %n) LoopDispositions: { %loop: Computable }
418 ; CHECK-NEXT:    %i.next = add i32 %i, 1
419 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: [1,44) S: [1,44) Exits: (1 + (42 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
420 ; CHECK-NEXT:    %umin = call i32 @llvm.umin.i32(i32 %n, i32 42)
421 ; CHECK-NEXT:    --> (42 umin %n) U: [0,43) S: [0,43) Exits: (42 umin %n) LoopDispositions: { %loop: Invariant }
422 ; CHECK-NEXT:    %cond = select i1 %cond_p1, i1 true, i1 %cond_p0
423 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
424 ; CHECK-NEXT:  Determining loop execution counts for: @logical_and_2ops_and_constant
425 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (42 umin %n)
426 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is 42
427 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (42 umin %n)
428 ; CHECK-NEXT:   Predicates:
429 ; CHECK:       Loop %loop: Trip multiple is 1
431 entry:
432   br label %loop
433 loop:
434   %i = phi i32 [0, %entry], [%i.next, %loop]
435   %i.next = add i32 %i, 1
436   %umin = call i32 @llvm.umin.i32(i32 %n, i32 42)
437   %cond_p0 = icmp uge i32 %i, %umin
438   %cond_p1 = icmp uge i32 %i, %n
439   %cond = select i1 %cond_p1, i1 true, i1 %cond_p0
440   br i1 %cond, label %exit, label %loop
441 exit:
442   ret i32 %i
445 define i32 @computeSCEVAtScope(i32 %d.0) {
446 ; CHECK-LABEL: 'computeSCEVAtScope'
447 ; CHECK-NEXT:  Classifying expressions for: @computeSCEVAtScope
448 ; CHECK-NEXT:    %d.1 = phi i32 [ %inc, %for.body ], [ %d.0, %for.cond.preheader ]
449 ; CHECK-NEXT:    --> {%d.0,+,1}<nsw><%for.cond> U: full-set S: full-set Exits: 0 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
450 ; CHECK-NEXT:    %e.1 = phi i32 [ %inc3, %for.body ], [ %d.0, %for.cond.preheader ]
451 ; CHECK-NEXT:    --> {%d.0,+,1}<nsw><%for.cond> U: full-set S: full-set Exits: 0 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
452 ; CHECK-NEXT:    %0 = select i1 %tobool1, i1 %tobool2, i1 false
453 ; CHECK-NEXT:    --> %0 U: full-set S: full-set Exits: false LoopDispositions: { %for.cond: Variant, %while.cond: Variant }
454 ; CHECK-NEXT:    %inc = add nsw i32 %d.1, 1
455 ; CHECK-NEXT:    --> {(1 + %d.0),+,1}<nw><%for.cond> U: full-set S: full-set Exits: 1 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
456 ; CHECK-NEXT:    %inc3 = add nsw i32 %e.1, 1
457 ; CHECK-NEXT:    --> {(1 + %d.0),+,1}<nw><%for.cond> U: full-set S: full-set Exits: 1 LoopDispositions: { %for.cond: Computable, %while.cond: Variant }
458 ; CHECK-NEXT:    %f.1 = phi i32 [ %inc8, %for.body5 ], [ 0, %for.cond4.preheader ]
459 ; CHECK-NEXT:    --> {0,+,1}<%for.cond4> U: [0,1) S: [0,1) Exits: 0 LoopDispositions: { %for.cond4: Computable, %while.cond: Variant }
460 ; CHECK-NEXT:    %inc8 = add i32 %f.1, 1
461 ; CHECK-NEXT:    --> {1,+,1}<%for.cond4> U: [1,2) S: [1,2) Exits: 1 LoopDispositions: { %for.cond4: Computable, %while.cond: Variant }
462 ; CHECK-NEXT:  Determining loop execution counts for: @computeSCEVAtScope
463 ; CHECK-NEXT:  Loop %for.cond: backedge-taken count is (-1 * %d.0)
464 ; CHECK-NEXT:  Loop %for.cond: max backedge-taken count is -1
465 ; CHECK-NEXT:  Loop %for.cond: Predicated backedge-taken count is (-1 * %d.0)
466 ; CHECK-NEXT:   Predicates:
467 ; CHECK:       Loop %for.cond: Trip multiple is 1
468 ; CHECK-NEXT:  Loop %for.cond4: backedge-taken count is 0
469 ; CHECK-NEXT:  Loop %for.cond4: max backedge-taken count is 0
470 ; CHECK-NEXT:  Loop %for.cond4: Predicated backedge-taken count is 0
471 ; CHECK-NEXT:   Predicates:
472 ; CHECK:       Loop %for.cond4: Trip multiple is 1
473 ; CHECK-NEXT:  Loop %while.cond: <multiple exits> Unpredictable backedge-taken count.
474 ; CHECK-NEXT:  Loop %while.cond: Unpredictable max backedge-taken count.
475 ; CHECK-NEXT:  Loop %while.cond: Unpredictable predicated backedge-taken count.
477 entry:
478   br label %while.cond
480 while.cond.loopexit:                              ; preds = %for.cond4
481   br label %while.cond
483 while.cond:                                       ; preds = %while.cond.loopexit, %entry
484   br label %for.cond.preheader
486 for.cond.preheader:                               ; preds = %while.cond
487   br label %for.cond
489 for.cond:                                         ; preds = %for.body, %for.cond.preheader
490   %d.1 = phi i32 [ %inc, %for.body ], [ %d.0, %for.cond.preheader ]
491   %e.1 = phi i32 [ %inc3, %for.body ], [ %d.0, %for.cond.preheader ]
492   %tobool1 = icmp ne i32 %e.1, 0
493   %tobool2 = icmp ne i32 %d.1, 0
494   %0 = select i1 %tobool1, i1 %tobool2, i1 false
495   br i1 %0, label %for.body, label %for.cond4.preheader
497 for.cond4.preheader:                              ; preds = %for.cond
498   br label %for.cond4
500 for.body:                                         ; preds = %for.cond
501   %inc = add nsw i32 %d.1, 1
502   %inc3 = add nsw i32 %e.1, 1
503   br label %for.cond
505 for.cond4:                                        ; preds = %for.body5, %for.cond4.preheader
506   %f.1 = phi i32 [ %inc8, %for.body5 ], [ 0, %for.cond4.preheader ]
507   %exitcond.not = icmp eq i32 %f.1, %e.1
508   br i1 %exitcond.not, label %while.cond.loopexit, label %for.body5
510 for.body5:                                        ; preds = %for.cond4
511   %inc8 = add i32 %f.1, 1
512   br label %for.cond4
515 define i64 @uminseq_vs_ptrtoint_complexity(i64 %n, i64 %m, i64* %ptr) {
516 ; CHECK-LABEL: 'uminseq_vs_ptrtoint_complexity'
517 ; CHECK-NEXT:  Classifying expressions for: @uminseq_vs_ptrtoint_complexity
518 ; CHECK-NEXT:    %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
519 ; CHECK-NEXT:    --> {0,+,1}<%loop> U: full-set S: full-set Exits: (%n umin_seq %m) LoopDispositions: { %loop: Computable }
520 ; CHECK-NEXT:    %i.next = add i64 %i, 1
521 ; CHECK-NEXT:    --> {1,+,1}<%loop> U: full-set S: full-set Exits: (1 + (%n umin_seq %m)) LoopDispositions: { %loop: Computable }
522 ; CHECK-NEXT:    %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
523 ; CHECK-NEXT:    --> %cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
524 ; CHECK-NEXT:    %ptr.int = ptrtoint i64* %ptr to i64
525 ; CHECK-NEXT:    --> (ptrtoint i64* %ptr to i64) U: full-set S: full-set
526 ; CHECK-NEXT:    %r = add i64 %i, %ptr.int
527 ; CHECK-NEXT:    --> {(ptrtoint i64* %ptr to i64),+,1}<%loop> U: full-set S: full-set --> ((%n umin_seq %m) + (ptrtoint i64* %ptr to i64)) U: full-set S: full-set
528 ; CHECK-NEXT:  Determining loop execution counts for: @uminseq_vs_ptrtoint_complexity
529 ; CHECK-NEXT:  Loop %loop: backedge-taken count is (%n umin_seq %m)
530 ; CHECK-NEXT:  Loop %loop: max backedge-taken count is -1
531 ; CHECK-NEXT:  Loop %loop: Predicated backedge-taken count is (%n umin_seq %m)
532 ; CHECK-NEXT:   Predicates:
533 ; CHECK:       Loop %loop: Trip multiple is 1
535 entry:
536   br label %loop
537 loop:
538   %i = phi i64 [0, %entry], [%i.next, %loop]
539   %i.next = add i64 %i, 1
540   %cond_p0 = icmp ult i64 %i, %n
541   %cond_p1 = icmp ult i64 %i, %m
542   %cond = select i1 %cond_p0, i1 %cond_p1, i1 false
543   br i1 %cond, label %loop, label %exit
544 exit:
545   %ptr.int = ptrtoint i64* %ptr to i64
546   %r = add i64 %i, %ptr.int
547   ret i64 %r
550 declare i32 @llvm.umin.i32(i32, i32)