1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define i32 @main1(i32 %argc) {
6 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 3
7 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 3
8 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
9 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
11 %and = and i32 %argc, 1
12 %tobool = icmp ne i32 %and, 0
13 %and2 = and i32 %argc, 2
14 %tobool3 = icmp ne i32 %and2, 0
15 %or.cond = and i1 %tobool, %tobool3
16 %retval.0 = select i1 %or.cond, i32 2, i32 1
20 define i32 @main1_logical(i32 %argc) {
21 ; CHECK-LABEL: @main1_logical(
22 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 3
23 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 3
24 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
25 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
27 %and = and i32 %argc, 1
28 %tobool = icmp ne i32 %and, 0
29 %and2 = and i32 %argc, 2
30 %tobool3 = icmp ne i32 %and2, 0
31 %or.cond = select i1 %tobool, i1 %tobool3, i1 false
32 %retval.0 = select i1 %or.cond, i32 2, i32 1
36 define i32 @main2(i32 %argc) {
37 ; CHECK-LABEL: @main2(
38 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 3
39 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 3
40 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
41 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
43 %and = and i32 %argc, 1
44 %tobool = icmp eq i32 %and, 0
45 %and2 = and i32 %argc, 2
46 %tobool3 = icmp eq i32 %and2, 0
47 %or.cond = or i1 %tobool, %tobool3
48 %storemerge = select i1 %or.cond, i32 0, i32 1
52 define i32 @main2_logical(i32 %argc) {
53 ; CHECK-LABEL: @main2_logical(
54 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 3
55 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 3
56 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
57 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
59 %and = and i32 %argc, 1
60 %tobool = icmp eq i32 %and, 0
61 %and2 = and i32 %argc, 2
62 %tobool3 = icmp eq i32 %and2, 0
63 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
64 %storemerge = select i1 %or.cond, i32 0, i32 1
68 ; tests to check combining (icmp eq (A & B), C) & (icmp eq (A & D), E)
69 ; tests to check if (icmp eq (A & B), 0) is treated like (icmp eq (A & B), B)
70 ; if B is a single bit constant
72 ; (icmp eq (A & B), 0) & (icmp eq (A & D), 0) -> (icmp eq (A & (B|D)), 0)
73 define i32 @main3(i32 %argc) {
74 ; CHECK-LABEL: @main3(
75 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
76 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
77 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
78 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
80 %and = and i32 %argc, 7
81 %tobool = icmp eq i32 %and, 0
82 %and2 = and i32 %argc, 48
83 %tobool3 = icmp eq i32 %and2, 0
84 %and.cond = and i1 %tobool, %tobool3
85 %storemerge = select i1 %and.cond, i32 0, i32 1
89 define i32 @main3_logical(i32 %argc) {
90 ; CHECK-LABEL: @main3_logical(
91 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
92 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
93 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
94 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
96 %and = and i32 %argc, 7
97 %tobool = icmp eq i32 %and, 0
98 %and2 = and i32 %argc, 48
99 %tobool3 = icmp eq i32 %and2, 0
100 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
101 %storemerge = select i1 %and.cond, i32 0, i32 1
105 define i32 @main3b(i32 %argc) {
106 ; CHECK-LABEL: @main3b(
107 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
108 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
109 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
110 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
112 %and = and i32 %argc, 7
113 %tobool = icmp eq i32 %and, 0
114 %and2 = and i32 %argc, 16
115 %tobool3 = icmp ne i32 %and2, 16
116 %and.cond = and i1 %tobool, %tobool3
117 %storemerge = select i1 %and.cond, i32 0, i32 1
121 define i32 @main3b_logical(i32 %argc) {
122 ; CHECK-LABEL: @main3b_logical(
123 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
124 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
125 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
126 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
128 %and = and i32 %argc, 7
129 %tobool = icmp eq i32 %and, 0
130 %and2 = and i32 %argc, 16
131 %tobool3 = icmp ne i32 %and2, 16
132 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
133 %storemerge = select i1 %and.cond, i32 0, i32 1
137 define i32 @main3e_like(i32 %argc, i32 %argc2, i32 %argc3) {
138 ; CHECK-LABEL: @main3e_like(
139 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
140 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
141 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
142 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
143 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
145 %and = and i32 %argc, %argc2
146 %tobool = icmp eq i32 %and, 0
147 %and2 = and i32 %argc, %argc3
148 %tobool3 = icmp eq i32 %and2, 0
149 %and.cond = and i1 %tobool, %tobool3
150 %storemerge = select i1 %and.cond, i32 0, i32 1
154 define i32 @main3e_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
155 ; CHECK-LABEL: @main3e_like_logical(
156 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
157 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND]], 0
158 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
159 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], 0
160 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
161 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
162 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
164 %and = and i32 %argc, %argc2
165 %tobool = icmp eq i32 %and, 0
166 %and2 = and i32 %argc, %argc3
167 %tobool3 = icmp eq i32 %and2, 0
168 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
169 %storemerge = select i1 %and.cond, i32 0, i32 1
173 ; (icmp ne (A & B), 0) | (icmp ne (A & D), 0) -> (icmp ne (A & (B|D)), 0)
174 define i32 @main3c(i32 %argc) {
175 ; CHECK-LABEL: @main3c(
176 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
177 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
178 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
179 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
181 %and = and i32 %argc, 7
182 %tobool = icmp ne i32 %and, 0
183 %and2 = and i32 %argc, 48
184 %tobool3 = icmp ne i32 %and2, 0
185 %or.cond = or i1 %tobool, %tobool3
186 %storemerge = select i1 %or.cond, i32 0, i32 1
190 define i32 @main3c_logical(i32 %argc) {
191 ; CHECK-LABEL: @main3c_logical(
192 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
193 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
194 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
195 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
197 %and = and i32 %argc, 7
198 %tobool = icmp ne i32 %and, 0
199 %and2 = and i32 %argc, 48
200 %tobool3 = icmp ne i32 %and2, 0
201 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
202 %storemerge = select i1 %or.cond, i32 0, i32 1
206 define i32 @main3d(i32 %argc) {
207 ; CHECK-LABEL: @main3d(
208 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
209 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
210 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
211 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
213 %and = and i32 %argc, 7
214 %tobool = icmp ne i32 %and, 0
215 %and2 = and i32 %argc, 16
216 %tobool3 = icmp eq i32 %and2, 16
217 %or.cond = or i1 %tobool, %tobool3
218 %storemerge = select i1 %or.cond, i32 0, i32 1
222 define i32 @main3d_logical(i32 %argc) {
223 ; CHECK-LABEL: @main3d_logical(
224 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
225 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
226 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
227 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
229 %and = and i32 %argc, 7
230 %tobool = icmp ne i32 %and, 0
231 %and2 = and i32 %argc, 16
232 %tobool3 = icmp eq i32 %and2, 16
233 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
234 %storemerge = select i1 %or.cond, i32 0, i32 1
238 define i32 @main3f_like(i32 %argc, i32 %argc2, i32 %argc3) {
239 ; CHECK-LABEL: @main3f_like(
240 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
241 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
242 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP2]], 0
243 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
244 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
246 %and = and i32 %argc, %argc2
247 %tobool = icmp ne i32 %and, 0
248 %and2 = and i32 %argc, %argc3
249 %tobool3 = icmp ne i32 %and2, 0
250 %or.cond = or i1 %tobool, %tobool3
251 %storemerge = select i1 %or.cond, i32 0, i32 1
255 define i32 @main3f_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
256 ; CHECK-LABEL: @main3f_like_logical(
257 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
258 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[AND]], 0
259 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
260 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp eq i32 [[AND2]], 0
261 ; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[TOBOOL]], i1 [[TOBOOL3]], i1 false
262 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[OR_COND]] to i32
263 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
265 %and = and i32 %argc, %argc2
266 %tobool = icmp ne i32 %and, 0
267 %and2 = and i32 %argc, %argc3
268 %tobool3 = icmp ne i32 %and2, 0
269 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
270 %storemerge = select i1 %or.cond, i32 0, i32 1
274 ; (icmp eq (A & B), B) & (icmp eq (A & D), D) -> (icmp eq (A & (B|D)), (B|D))
275 define i32 @main4(i32 %argc) {
276 ; CHECK-LABEL: @main4(
277 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
278 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 55
279 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
280 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
282 %and = and i32 %argc, 7
283 %tobool = icmp eq i32 %and, 7
284 %and2 = and i32 %argc, 48
285 %tobool3 = icmp eq i32 %and2, 48
286 %and.cond = and i1 %tobool, %tobool3
287 %storemerge = select i1 %and.cond, i32 0, i32 1
291 define i32 @main4_logical(i32 %argc) {
292 ; CHECK-LABEL: @main4_logical(
293 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
294 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 55
295 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
296 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
298 %and = and i32 %argc, 7
299 %tobool = icmp eq i32 %and, 7
300 %and2 = and i32 %argc, 48
301 %tobool3 = icmp eq i32 %and2, 48
302 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
303 %storemerge = select i1 %and.cond, i32 0, i32 1
307 define i32 @main4b(i32 %argc) {
308 ; CHECK-LABEL: @main4b(
309 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
310 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 23
311 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
312 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
314 %and = and i32 %argc, 7
315 %tobool = icmp eq i32 %and, 7
316 %and2 = and i32 %argc, 16
317 %tobool3 = icmp ne i32 %and2, 0
318 %and.cond = and i1 %tobool, %tobool3
319 %storemerge = select i1 %and.cond, i32 0, i32 1
323 define i32 @main4b_logical(i32 %argc) {
324 ; CHECK-LABEL: @main4b_logical(
325 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
326 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 23
327 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
328 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
330 %and = and i32 %argc, 7
331 %tobool = icmp eq i32 %and, 7
332 %and2 = and i32 %argc, 16
333 %tobool3 = icmp ne i32 %and2, 0
334 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
335 %storemerge = select i1 %and.cond, i32 0, i32 1
339 define i32 @main4e_like(i32 %argc, i32 %argc2, i32 %argc3) {
340 ; CHECK-LABEL: @main4e_like(
341 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
342 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
343 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
344 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
345 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
347 %and = and i32 %argc, %argc2
348 %tobool = icmp eq i32 %and, %argc2
349 %and2 = and i32 %argc, %argc3
350 %tobool3 = icmp eq i32 %and2, %argc3
351 %and.cond = and i1 %tobool, %tobool3
352 %storemerge = select i1 %and.cond, i32 0, i32 1
356 define i32 @main4e_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
357 ; CHECK-LABEL: @main4e_like_logical(
358 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
359 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND]], [[ARGC2]]
360 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
361 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[ARGC3]]
362 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
363 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
364 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
366 %and = and i32 %argc, %argc2
367 %tobool = icmp eq i32 %and, %argc2
368 %and2 = and i32 %argc, %argc3
369 %tobool3 = icmp eq i32 %and2, %argc3
370 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
371 %storemerge = select i1 %and.cond, i32 0, i32 1
375 ; (icmp ne (A & B), B) | (icmp ne (A & D), D) -> (icmp ne (A & (B|D)), (B|D))
376 define i32 @main4c(i32 %argc) {
377 ; CHECK-LABEL: @main4c(
378 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
379 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 55
380 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
381 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
383 %and = and i32 %argc, 7
384 %tobool = icmp ne i32 %and, 7
385 %and2 = and i32 %argc, 48
386 %tobool3 = icmp ne i32 %and2, 48
387 %or.cond = or i1 %tobool, %tobool3
388 %storemerge = select i1 %or.cond, i32 0, i32 1
392 define i32 @main4c_logical(i32 %argc) {
393 ; CHECK-LABEL: @main4c_logical(
394 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
395 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 55
396 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
397 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
399 %and = and i32 %argc, 7
400 %tobool = icmp ne i32 %and, 7
401 %and2 = and i32 %argc, 48
402 %tobool3 = icmp ne i32 %and2, 48
403 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
404 %storemerge = select i1 %or.cond, i32 0, i32 1
408 define i32 @main4d(i32 %argc) {
409 ; CHECK-LABEL: @main4d(
410 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
411 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 23
412 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
413 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
415 %and = and i32 %argc, 7
416 %tobool = icmp ne i32 %and, 7
417 %and2 = and i32 %argc, 16
418 %tobool3 = icmp eq i32 %and2, 0
419 %or.cond = or i1 %tobool, %tobool3
420 %storemerge = select i1 %or.cond, i32 0, i32 1
424 define i32 @main4d_logical(i32 %argc) {
425 ; CHECK-LABEL: @main4d_logical(
426 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
427 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 23
428 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
429 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
431 %and = and i32 %argc, 7
432 %tobool = icmp ne i32 %and, 7
433 %and2 = and i32 %argc, 16
434 %tobool3 = icmp eq i32 %and2, 0
435 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
436 %storemerge = select i1 %or.cond, i32 0, i32 1
440 define i32 @main4f_like(i32 %argc, i32 %argc2, i32 %argc3) {
441 ; CHECK-LABEL: @main4f_like(
442 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
443 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
444 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP2]], [[TMP1]]
445 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
446 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
448 %and = and i32 %argc, %argc2
449 %tobool = icmp ne i32 %and, %argc2
450 %and2 = and i32 %argc, %argc3
451 %tobool3 = icmp ne i32 %and2, %argc3
452 %or.cond = or i1 %tobool, %tobool3
453 %storemerge = select i1 %or.cond, i32 0, i32 1
457 define i32 @main4f_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
458 ; CHECK-LABEL: @main4f_like_logical(
459 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
460 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[AND]], [[ARGC2]]
461 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
462 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp eq i32 [[AND2]], [[ARGC3]]
463 ; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[TOBOOL]], i1 [[TOBOOL3]], i1 false
464 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[OR_COND]] to i32
465 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
467 %and = and i32 %argc, %argc2
468 %tobool = icmp ne i32 %and, %argc2
469 %and2 = and i32 %argc, %argc3
470 %tobool3 = icmp ne i32 %and2, %argc3
471 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
472 %storemerge = select i1 %or.cond, i32 0, i32 1
476 ; (icmp eq (A & B), A) & (icmp eq (A & D), A) -> (icmp eq (A & (B&D)), A)
477 define i32 @main5_like(i32 %argc, i32 %argc2) {
478 ; CHECK-LABEL: @main5_like(
479 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
480 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 7
481 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 7
482 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
483 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
485 %and = and i32 %argc, 7
486 %tobool = icmp eq i32 %and, 7
487 %and2 = and i32 %argc2, 7
488 %tobool3 = icmp eq i32 %and2, 7
489 %and.cond = and i1 %tobool, %tobool3
490 %storemerge = select i1 %and.cond, i32 0, i32 1
494 define i32 @main5_like_logical(i32 %argc, i32 %argc2) {
495 ; CHECK-LABEL: @main5_like_logical(
496 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], 7
497 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND]], 7
498 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC2:%.*]], 7
499 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], 7
500 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
501 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
502 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
504 %and = and i32 %argc, 7
505 %tobool = icmp eq i32 %and, 7
506 %and2 = and i32 %argc2, 7
507 %tobool3 = icmp eq i32 %and2, 7
508 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
509 %storemerge = select i1 %and.cond, i32 0, i32 1
513 define i32 @main5e_like(i32 %argc, i32 %argc2, i32 %argc3) {
514 ; CHECK-LABEL: @main5e_like(
515 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
516 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
517 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[ARGC]]
518 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
519 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
521 %and = and i32 %argc, %argc2
522 %tobool = icmp eq i32 %and, %argc
523 %and2 = and i32 %argc, %argc3
524 %tobool3 = icmp eq i32 %and2, %argc
525 %and.cond = and i1 %tobool, %tobool3
526 %storemerge = select i1 %and.cond, i32 0, i32 1
530 define i32 @main5e_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
531 ; CHECK-LABEL: @main5e_like_logical(
532 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
533 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND]], [[ARGC]]
534 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
535 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[ARGC]]
536 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
537 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
538 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
540 %and = and i32 %argc, %argc2
541 %tobool = icmp eq i32 %and, %argc
542 %and2 = and i32 %argc, %argc3
543 %tobool3 = icmp eq i32 %and2, %argc
544 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
545 %storemerge = select i1 %and.cond, i32 0, i32 1
549 ; (icmp ne (A & B), A) | (icmp ne (A & D), A) -> (icmp ne (A & (B&D)), A)
550 define i32 @main5c_like(i32 %argc, i32 %argc2) {
551 ; CHECK-LABEL: @main5c_like(
552 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
553 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 7
554 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP2]], 7
555 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
556 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
558 %and = and i32 %argc, 7
559 %tobool = icmp ne i32 %and, 7
560 %and2 = and i32 %argc2, 7
561 %tobool3 = icmp ne i32 %and2, 7
562 %or.cond = or i1 %tobool, %tobool3
563 %storemerge = select i1 %or.cond, i32 0, i32 1
567 define i32 @main5c_like_logical(i32 %argc, i32 %argc2) {
568 ; CHECK-LABEL: @main5c_like_logical(
569 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], 7
570 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[AND]], 7
571 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC2:%.*]], 7
572 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp eq i32 [[AND2]], 7
573 ; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[TOBOOL]], i1 [[TOBOOL3]], i1 false
574 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[OR_COND]] to i32
575 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
577 %and = and i32 %argc, 7
578 %tobool = icmp ne i32 %and, 7
579 %and2 = and i32 %argc2, 7
580 %tobool3 = icmp ne i32 %and2, 7
581 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
582 %storemerge = select i1 %or.cond, i32 0, i32 1
586 define i32 @main5f_like(i32 %argc, i32 %argc2, i32 %argc3) {
587 ; CHECK-LABEL: @main5f_like(
588 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
589 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
590 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP2]], [[ARGC]]
591 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
592 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
594 %and = and i32 %argc, %argc2
595 %tobool = icmp ne i32 %and, %argc
596 %and2 = and i32 %argc, %argc3
597 %tobool3 = icmp ne i32 %and2, %argc
598 %or.cond = or i1 %tobool, %tobool3
599 %storemerge = select i1 %or.cond, i32 0, i32 1
603 define i32 @main5f_like_logical(i32 %argc, i32 %argc2, i32 %argc3) {
604 ; CHECK-LABEL: @main5f_like_logical(
605 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
606 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[AND]], [[ARGC]]
607 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
608 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp eq i32 [[AND2]], [[ARGC]]
609 ; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[TOBOOL]], i1 [[TOBOOL3]], i1 false
610 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[OR_COND]] to i32
611 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
613 %and = and i32 %argc, %argc2
614 %tobool = icmp ne i32 %and, %argc
615 %and2 = and i32 %argc, %argc3
616 %tobool3 = icmp ne i32 %and2, %argc
617 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
618 %storemerge = select i1 %or.cond, i32 0, i32 1
622 ; (icmp eq (A & B), C) & (icmp eq (A & D), E) -> (icmp eq (A & (B|D)), (C|E))
623 ; if B, C, D, E are constant, and it's possible
624 define i32 @main6(i32 %argc) {
625 ; CHECK-LABEL: @main6(
626 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
627 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 19
628 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
629 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
631 %and = and i32 %argc, 7
632 %tobool = icmp eq i32 %and, 3
633 %and2 = and i32 %argc, 48
634 %tobool3 = icmp eq i32 %and2, 16
635 %and.cond = and i1 %tobool, %tobool3
636 %storemerge = select i1 %and.cond, i32 0, i32 1
640 define i32 @main6_logical(i32 %argc) {
641 ; CHECK-LABEL: @main6_logical(
642 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
643 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 19
644 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
645 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
647 %and = and i32 %argc, 7
648 %tobool = icmp eq i32 %and, 3
649 %and2 = and i32 %argc, 48
650 %tobool3 = icmp eq i32 %and2, 16
651 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
652 %storemerge = select i1 %and.cond, i32 0, i32 1
656 define i32 @main6b(i32 %argc) {
657 ; CHECK-LABEL: @main6b(
658 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
659 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 19
660 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
661 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
663 %and = and i32 %argc, 7
664 %tobool = icmp eq i32 %and, 3
665 %and2 = and i32 %argc, 16
666 %tobool3 = icmp ne i32 %and2, 0
667 %and.cond = and i1 %tobool, %tobool3
668 %storemerge = select i1 %and.cond, i32 0, i32 1
672 define i32 @main6b_logical(i32 %argc) {
673 ; CHECK-LABEL: @main6b_logical(
674 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
675 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 19
676 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP2]] to i32
677 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
679 %and = and i32 %argc, 7
680 %tobool = icmp eq i32 %and, 3
681 %and2 = and i32 %argc, 16
682 %tobool3 = icmp ne i32 %and2, 0
683 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
684 %storemerge = select i1 %and.cond, i32 0, i32 1
688 ; (icmp ne (A & B), C) | (icmp ne (A & D), E) -> (icmp ne (A & (B|D)), (C|E))
689 ; if B, C, D, E are constant, and it's possible
690 define i32 @main6c(i32 %argc) {
691 ; CHECK-LABEL: @main6c(
692 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
693 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 19
694 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
695 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
697 %and = and i32 %argc, 7
698 %tobool = icmp ne i32 %and, 3
699 %and2 = and i32 %argc, 48
700 %tobool3 = icmp ne i32 %and2, 16
701 %or.cond = or i1 %tobool, %tobool3
702 %storemerge = select i1 %or.cond, i32 0, i32 1
706 define i32 @main6c_logical(i32 %argc) {
707 ; CHECK-LABEL: @main6c_logical(
708 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 55
709 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 19
710 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
711 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
713 %and = and i32 %argc, 7
714 %tobool = icmp ne i32 %and, 3
715 %and2 = and i32 %argc, 48
716 %tobool3 = icmp ne i32 %and2, 16
717 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
718 %storemerge = select i1 %or.cond, i32 0, i32 1
722 define i32 @main6d(i32 %argc) {
723 ; CHECK-LABEL: @main6d(
724 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
725 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 19
726 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
727 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
729 %and = and i32 %argc, 7
730 %tobool = icmp ne i32 %and, 3
731 %and2 = and i32 %argc, 16
732 %tobool3 = icmp eq i32 %and2, 0
733 %or.cond = or i1 %tobool, %tobool3
734 %storemerge = select i1 %or.cond, i32 0, i32 1
738 define i32 @main6d_logical(i32 %argc) {
739 ; CHECK-LABEL: @main6d_logical(
740 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 23
741 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 19
742 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[DOTNOT]] to i32
743 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
745 %and = and i32 %argc, 7
746 %tobool = icmp ne i32 %and, 3
747 %and2 = and i32 %argc, 16
748 %tobool3 = icmp eq i32 %and2, 0
749 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
750 %storemerge = select i1 %or.cond, i32 0, i32 1
754 ; test parameter permutations
755 ; (B & A) == B & (D & A) == D
756 define i32 @main7a(i32 %argc, i32 %argc2, i32 %argc3) {
757 ; CHECK-LABEL: @main7a(
758 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
759 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
760 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
761 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
762 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
764 %and1 = and i32 %argc2, %argc
765 %tobool = icmp eq i32 %and1, %argc2
766 %and2 = and i32 %argc3, %argc
767 %tobool3 = icmp eq i32 %and2, %argc3
768 %and.cond = and i1 %tobool, %tobool3
769 %storemerge = select i1 %and.cond, i32 0, i32 1
773 define i32 @main7a_logical(i32 %argc, i32 %argc2, i32 %argc3) {
774 ; CHECK-LABEL: @main7a_logical(
775 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC:%.*]]
776 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND1]], [[ARGC2]]
777 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC]]
778 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[ARGC3]]
779 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
780 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
781 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
783 %and1 = and i32 %argc2, %argc
784 %tobool = icmp eq i32 %and1, %argc2
785 %and2 = and i32 %argc3, %argc
786 %tobool3 = icmp eq i32 %and2, %argc3
787 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
788 %storemerge = select i1 %and.cond, i32 0, i32 1
792 ; B == (A & B) & D == (A & D)
793 define i32 @main7b(i32 %argc, i32 %argc2, i32 %argc3) {
794 ; CHECK-LABEL: @main7b(
795 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
796 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
797 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
798 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
799 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
801 %and1 = and i32 %argc, %argc2
802 %tobool = icmp eq i32 %argc2, %and1
803 %and2 = and i32 %argc, %argc3
804 %tobool3 = icmp eq i32 %argc3, %and2
805 %and.cond = and i1 %tobool, %tobool3
806 %storemerge = select i1 %and.cond, i32 0, i32 1
810 define i32 @main7b_logical(i32 %argc, i32 %argc2, i32 %argc3) {
811 ; CHECK-LABEL: @main7b_logical(
812 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[ARGC:%.*]], [[ARGC2:%.*]]
813 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND1]], [[ARGC2]]
814 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC]], [[ARGC3:%.*]]
815 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[ARGC3]]
816 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
817 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
818 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
820 %and1 = and i32 %argc, %argc2
821 %tobool = icmp eq i32 %argc2, %and1
822 %and2 = and i32 %argc, %argc3
823 %tobool3 = icmp eq i32 %argc3, %and2
824 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
825 %storemerge = select i1 %and.cond, i32 0, i32 1
829 ; B == (B & A) & D == (D & A)
830 define i32 @main7c(i32 %argc, i32 %argc2, i32 %argc3) {
831 ; CHECK-LABEL: @main7c(
832 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[ARGC2:%.*]], [[ARGC3:%.*]]
833 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
834 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
835 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
836 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
838 %and1 = and i32 %argc2, %argc
839 %tobool = icmp eq i32 %argc2, %and1
840 %and2 = and i32 %argc3, %argc
841 %tobool3 = icmp eq i32 %argc3, %and2
842 %and.cond = and i1 %tobool, %tobool3
843 %storemerge = select i1 %and.cond, i32 0, i32 1
847 define i32 @main7c_logical(i32 %argc, i32 %argc2, i32 %argc3) {
848 ; CHECK-LABEL: @main7c_logical(
849 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC:%.*]]
850 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND1]], [[ARGC2]]
851 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC]]
852 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[ARGC3]]
853 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
854 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
855 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
857 %and1 = and i32 %argc2, %argc
858 %tobool = icmp eq i32 %argc2, %and1
859 %and2 = and i32 %argc3, %argc
860 %tobool3 = icmp eq i32 %argc3, %and2
861 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
862 %storemerge = select i1 %and.cond, i32 0, i32 1
866 ; (A & (B & C)) == (B & C) & (A & (D & E)) == (D & E)
867 define i32 @main7d(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
868 ; CHECK-LABEL: @main7d(
869 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
870 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
871 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[BC]], [[DE]]
872 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
873 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
874 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
875 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
877 %bc = and i32 %argc2, %argc4
878 %de = and i32 %argc3, %argc5
879 %and1 = and i32 %argc, %bc
880 %tobool = icmp eq i32 %and1, %bc
881 %and2 = and i32 %argc, %de
882 %tobool3 = icmp eq i32 %and2, %de
883 %and.cond = and i1 %tobool, %tobool3
884 %storemerge = select i1 %and.cond, i32 0, i32 1
888 define i32 @main7d_logical(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
889 ; CHECK-LABEL: @main7d_logical(
890 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
891 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
892 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[BC]], [[ARGC:%.*]]
893 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND1]], [[BC]]
894 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[DE]], [[ARGC]]
895 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[DE]]
896 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
897 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
898 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
900 %bc = and i32 %argc2, %argc4
901 %de = and i32 %argc3, %argc5
902 %and1 = and i32 %argc, %bc
903 %tobool = icmp eq i32 %and1, %bc
904 %and2 = and i32 %argc, %de
905 %tobool3 = icmp eq i32 %and2, %de
906 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
907 %storemerge = select i1 %and.cond, i32 0, i32 1
911 ; ((B & C) & A) == (B & C) & ((D & E) & A) == (D & E)
912 define i32 @main7e(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
913 ; CHECK-LABEL: @main7e(
914 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
915 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
916 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[BC]], [[DE]]
917 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
918 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
919 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
920 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
922 %bc = and i32 %argc2, %argc4
923 %de = and i32 %argc3, %argc5
924 %and1 = and i32 %bc, %argc
925 %tobool = icmp eq i32 %and1, %bc
926 %and2 = and i32 %de, %argc
927 %tobool3 = icmp eq i32 %and2, %de
928 %and.cond = and i1 %tobool, %tobool3
929 %storemerge = select i1 %and.cond, i32 0, i32 1
933 define i32 @main7e_logical(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
934 ; CHECK-LABEL: @main7e_logical(
935 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
936 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
937 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[BC]], [[ARGC:%.*]]
938 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[AND1]], [[BC]]
939 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[DE]], [[ARGC]]
940 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[AND2]], [[DE]]
941 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
942 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
943 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
945 %bc = and i32 %argc2, %argc4
946 %de = and i32 %argc3, %argc5
947 %and1 = and i32 %bc, %argc
948 %tobool = icmp eq i32 %and1, %bc
949 %and2 = and i32 %de, %argc
950 %tobool3 = icmp eq i32 %and2, %de
951 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
952 %storemerge = select i1 %and.cond, i32 0, i32 1
956 ; (B & C) == (A & (B & C)) & (D & E) == (A & (D & E))
957 define i32 @main7f(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
958 ; CHECK-LABEL: @main7f(
959 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
960 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
961 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[BC]], [[DE]]
962 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
963 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
964 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
965 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
967 %bc = and i32 %argc2, %argc4
968 %de = and i32 %argc3, %argc5
969 %and1 = and i32 %argc, %bc
970 %tobool = icmp eq i32 %bc, %and1
971 %and2 = and i32 %argc, %de
972 %tobool3 = icmp eq i32 %de, %and2
973 %and.cond = and i1 %tobool, %tobool3
974 %storemerge = select i1 %and.cond, i32 0, i32 1
978 define i32 @main7f_logical(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
979 ; CHECK-LABEL: @main7f_logical(
980 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
981 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
982 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[BC]], [[ARGC:%.*]]
983 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[BC]], [[AND1]]
984 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[DE]], [[ARGC]]
985 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[DE]], [[AND2]]
986 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
987 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
988 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
990 %bc = and i32 %argc2, %argc4
991 %de = and i32 %argc3, %argc5
992 %and1 = and i32 %argc, %bc
993 %tobool = icmp eq i32 %bc, %and1
994 %and2 = and i32 %argc, %de
995 %tobool3 = icmp eq i32 %de, %and2
996 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
997 %storemerge = select i1 %and.cond, i32 0, i32 1
1001 ; (B & C) == ((B & C) & A) & (D & E) == ((D & E) & A)
1002 define i32 @main7g(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
1003 ; CHECK-LABEL: @main7g(
1004 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
1005 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
1006 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[BC]], [[DE]]
1007 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[ARGC:%.*]]
1008 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], [[TMP1]]
1009 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[TMP3]] to i32
1010 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
1012 %bc = and i32 %argc2, %argc4
1013 %de = and i32 %argc3, %argc5
1014 %and1 = and i32 %bc, %argc
1015 %tobool = icmp eq i32 %bc, %and1
1016 %and2 = and i32 %de, %argc
1017 %tobool3 = icmp eq i32 %de, %and2
1018 %and.cond = and i1 %tobool, %tobool3
1019 %storemerge = select i1 %and.cond, i32 0, i32 1
1023 define i32 @main7g_logical(i32 %argc, i32 %argc2, i32 %argc3, i32 %argc4, i32 %argc5) {
1024 ; CHECK-LABEL: @main7g_logical(
1025 ; CHECK-NEXT: [[BC:%.*]] = and i32 [[ARGC2:%.*]], [[ARGC4:%.*]]
1026 ; CHECK-NEXT: [[DE:%.*]] = and i32 [[ARGC3:%.*]], [[ARGC5:%.*]]
1027 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[BC]], [[ARGC:%.*]]
1028 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[BC]], [[AND1]]
1029 ; CHECK-NEXT: [[AND2:%.*]] = and i32 [[DE]], [[ARGC]]
1030 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[DE]], [[AND2]]
1031 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[TOBOOL]], i1 true, i1 [[TOBOOL3]]
1032 ; CHECK-NEXT: [[STOREMERGE:%.*]] = zext i1 [[AND_COND]] to i32
1033 ; CHECK-NEXT: ret i32 [[STOREMERGE]]
1035 %bc = and i32 %argc2, %argc4
1036 %de = and i32 %argc3, %argc5
1037 %and1 = and i32 %bc, %argc
1038 %tobool = icmp eq i32 %bc, %and1
1039 %and2 = and i32 %de, %argc
1040 %tobool3 = icmp eq i32 %de, %and2
1041 %and.cond = select i1 %tobool, i1 %tobool3, i1 false
1042 %storemerge = select i1 %and.cond, i32 0, i32 1
1046 define i32 @main8(i32 %argc) {
1047 ; CHECK-LABEL: @main8(
1048 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1049 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
1050 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1051 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1053 %and = and i32 %argc, 64
1054 %tobool = icmp ne i32 %and, 0
1055 %trunc2 = trunc i32 %argc to i8
1056 %tobool3 = icmp slt i8 %trunc2, 0
1057 %or.cond = or i1 %tobool, %tobool3
1058 %retval.0 = select i1 %or.cond, i32 2, i32 1
1062 define i32 @main8_logical(i32 %argc) {
1063 ; CHECK-LABEL: @main8_logical(
1064 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1065 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
1066 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1067 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1069 %and = and i32 %argc, 64
1070 %tobool = icmp ne i32 %and, 0
1071 %trunc2 = trunc i32 %argc to i8
1072 %tobool3 = icmp slt i8 %trunc2, 0
1073 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
1074 %retval.0 = select i1 %or.cond, i32 2, i32 1
1078 define i32 @main9(i32 %argc) {
1079 ; CHECK-LABEL: @main9(
1080 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1081 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 192
1082 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1083 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1085 %and = and i32 %argc, 64
1086 %tobool = icmp ne i32 %and, 0
1087 %trunc2 = trunc i32 %argc to i8
1088 %tobool3 = icmp slt i8 %trunc2, 0
1089 %or.cond = and i1 %tobool, %tobool3
1090 %retval.0 = select i1 %or.cond, i32 2, i32 1
1094 define i32 @main9_logical(i32 %argc) {
1095 ; CHECK-LABEL: @main9_logical(
1096 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1097 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 192
1098 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1099 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1101 %and = and i32 %argc, 64
1102 %tobool = icmp ne i32 %and, 0
1103 %trunc2 = trunc i32 %argc to i8
1104 %tobool3 = icmp slt i8 %trunc2, 0
1105 %or.cond = select i1 %tobool, i1 %tobool3, i1 false
1106 %retval.0 = select i1 %or.cond, i32 2, i32 1
1110 define i32 @main10(i32 %argc) {
1111 ; CHECK-LABEL: @main10(
1112 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1113 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
1114 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1115 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1117 %and = and i32 %argc, 64
1118 %tobool = icmp eq i32 %and, 0
1119 %trunc2 = trunc i32 %argc to i8
1120 %tobool3 = icmp sge i8 %trunc2, 0
1121 %or.cond = and i1 %tobool, %tobool3
1122 %retval.0 = select i1 %or.cond, i32 2, i32 1
1126 define i32 @main10_logical(i32 %argc) {
1127 ; CHECK-LABEL: @main10_logical(
1128 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1129 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
1130 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1131 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1133 %and = and i32 %argc, 64
1134 %tobool = icmp eq i32 %and, 0
1135 %trunc2 = trunc i32 %argc to i8
1136 %tobool3 = icmp sge i8 %trunc2, 0
1137 %or.cond = select i1 %tobool, i1 %tobool3, i1 false
1138 %retval.0 = select i1 %or.cond, i32 2, i32 1
1142 define i32 @main11(i32 %argc) {
1143 ; CHECK-LABEL: @main11(
1144 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1145 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 192
1146 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1147 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1149 %and = and i32 %argc, 64
1150 %tobool = icmp eq i32 %and, 0
1151 %trunc2 = trunc i32 %argc to i8
1152 %tobool3 = icmp sge i8 %trunc2, 0
1153 %or.cond = or i1 %tobool, %tobool3
1154 %retval.0 = select i1 %or.cond, i32 2, i32 1
1158 define i32 @main11_logical(i32 %argc) {
1159 ; CHECK-LABEL: @main11_logical(
1160 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 192
1161 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 192
1162 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1163 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1165 %and = and i32 %argc, 64
1166 %tobool = icmp eq i32 %and, 0
1167 %trunc2 = trunc i32 %argc to i8
1168 %tobool3 = icmp sge i8 %trunc2, 0
1169 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
1170 %retval.0 = select i1 %or.cond, i32 2, i32 1
1174 define i32 @main12(i32 %argc) {
1175 ; CHECK-LABEL: @main12(
1176 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1177 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
1178 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1179 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1181 %trunc = trunc i32 %argc to i16
1182 %tobool = icmp slt i16 %trunc, 0
1183 %trunc2 = trunc i32 %argc to i8
1184 %tobool3 = icmp slt i8 %trunc2, 0
1185 %or.cond = or i1 %tobool, %tobool3
1186 %retval.0 = select i1 %or.cond, i32 2, i32 1
1190 define i32 @main12_logical(i32 %argc) {
1191 ; CHECK-LABEL: @main12_logical(
1192 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1193 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 0
1194 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1195 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1197 %trunc = trunc i32 %argc to i16
1198 %tobool = icmp slt i16 %trunc, 0
1199 %trunc2 = trunc i32 %argc to i8
1200 %tobool3 = icmp slt i8 %trunc2, 0
1201 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
1202 %retval.0 = select i1 %or.cond, i32 2, i32 1
1206 define i32 @main13(i32 %argc) {
1207 ; CHECK-LABEL: @main13(
1208 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1209 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 32896
1210 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1211 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1213 %trunc = trunc i32 %argc to i16
1214 %tobool = icmp slt i16 %trunc, 0
1215 %trunc2 = trunc i32 %argc to i8
1216 %tobool3 = icmp slt i8 %trunc2, 0
1217 %or.cond = and i1 %tobool, %tobool3
1218 %retval.0 = select i1 %or.cond, i32 2, i32 1
1222 define i32 @main13_logical(i32 %argc) {
1223 ; CHECK-LABEL: @main13_logical(
1224 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1225 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 32896
1226 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1227 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1229 %trunc = trunc i32 %argc to i16
1230 %tobool = icmp slt i16 %trunc, 0
1231 %trunc2 = trunc i32 %argc to i8
1232 %tobool3 = icmp slt i8 %trunc2, 0
1233 %or.cond = select i1 %tobool, i1 %tobool3, i1 false
1234 %retval.0 = select i1 %or.cond, i32 2, i32 1
1238 define i32 @main14(i32 %argc) {
1239 ; CHECK-LABEL: @main14(
1240 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1241 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
1242 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1243 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1245 %trunc = trunc i32 %argc to i16
1246 %tobool = icmp sge i16 %trunc, 0
1247 %trunc2 = trunc i32 %argc to i8
1248 %tobool3 = icmp sge i8 %trunc2, 0
1249 %or.cond = and i1 %tobool, %tobool3
1250 %retval.0 = select i1 %or.cond, i32 2, i32 1
1254 define i32 @main14_logical(i32 %argc) {
1255 ; CHECK-LABEL: @main14_logical(
1256 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1257 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
1258 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[TMP2]], i32 2, i32 1
1259 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1261 %trunc = trunc i32 %argc to i16
1262 %tobool = icmp sge i16 %trunc, 0
1263 %trunc2 = trunc i32 %argc to i8
1264 %tobool3 = icmp sge i8 %trunc2, 0
1265 %or.cond = select i1 %tobool, i1 %tobool3, i1 false
1266 %retval.0 = select i1 %or.cond, i32 2, i32 1
1270 define i32 @main15(i32 %argc) {
1271 ; CHECK-LABEL: @main15(
1272 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1273 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 32896
1274 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1275 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1277 %trunc = trunc i32 %argc to i16
1278 %tobool = icmp sge i16 %trunc, 0
1279 %trunc2 = trunc i32 %argc to i8
1280 %tobool3 = icmp sge i8 %trunc2, 0
1281 %or.cond = or i1 %tobool, %tobool3
1282 %retval.0 = select i1 %or.cond, i32 2, i32 1
1286 define i32 @main15_logical(i32 %argc) {
1287 ; CHECK-LABEL: @main15_logical(
1288 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ARGC:%.*]], 32896
1289 ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP1]], 32896
1290 ; CHECK-NEXT: [[RETVAL_0:%.*]] = select i1 [[DOTNOT]], i32 1, i32 2
1291 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
1293 %trunc = trunc i32 %argc to i16
1294 %tobool = icmp sge i16 %trunc, 0
1295 %trunc2 = trunc i32 %argc to i8
1296 %tobool3 = icmp sge i8 %trunc2, 0
1297 %or.cond = select i1 %tobool, i1 true, i1 %tobool3
1298 %retval.0 = select i1 %or.cond, i32 2, i32 1