1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S -o - %s | FileCheck %s
4 define i1 @masked_and_notallzeroes(i32 %A) {
5 ; CHECK-LABEL: @masked_and_notallzeroes(
6 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
7 ; CHECK-NEXT: [[TST1:%.*]] = icmp ne i32 [[MASK1]], 0
8 ; CHECK-NEXT: ret i1 [[TST1]]
10 %mask1 = and i32 %A, 7
11 %tst1 = icmp ne i32 %mask1, 0
12 %mask2 = and i32 %A, 39
13 %tst2 = icmp ne i32 %mask2, 0
14 %res = and i1 %tst1, %tst2
18 define i1 @masked_and_notallzeroes_logical(i32 %A) {
19 ; CHECK-LABEL: @masked_and_notallzeroes_logical(
20 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
21 ; CHECK-NEXT: [[TST1:%.*]] = icmp ne i32 [[MASK1]], 0
22 ; CHECK-NEXT: ret i1 [[TST1]]
24 %mask1 = and i32 %A, 7
25 %tst1 = icmp ne i32 %mask1, 0
26 %mask2 = and i32 %A, 39
27 %tst2 = icmp ne i32 %mask2, 0
28 %res = select i1 %tst1, i1 %tst2, i1 false
32 define i1 @masked_or_allzeroes(i32 %A) {
33 ; CHECK-LABEL: @masked_or_allzeroes(
34 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
35 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 0
36 ; CHECK-NEXT: ret i1 [[TST1]]
38 %mask1 = and i32 %A, 7
39 %tst1 = icmp eq i32 %mask1, 0
40 %mask2 = and i32 %A, 39
41 %tst2 = icmp eq i32 %mask2, 0
42 %res = or i1 %tst1, %tst2
46 define i1 @masked_or_allzeroes_logical(i32 %A) {
47 ; CHECK-LABEL: @masked_or_allzeroes_logical(
48 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
49 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 0
50 ; CHECK-NEXT: ret i1 [[TST1]]
52 %mask1 = and i32 %A, 7
53 %tst1 = icmp eq i32 %mask1, 0
54 %mask2 = and i32 %A, 39
55 %tst2 = icmp eq i32 %mask2, 0
56 %res = select i1 %tst1, i1 true, i1 %tst2
60 define i1 @masked_and_notallones(i32 %A) {
61 ; CHECK-LABEL: @masked_and_notallones(
62 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
63 ; CHECK-NEXT: [[TST1:%.*]] = icmp ne i32 [[MASK1]], 7
64 ; CHECK-NEXT: ret i1 [[TST1]]
66 %mask1 = and i32 %A, 7
67 %tst1 = icmp ne i32 %mask1, 7
68 %mask2 = and i32 %A, 39
69 %tst2 = icmp ne i32 %mask2, 39
70 %res = and i1 %tst1, %tst2
74 define i1 @masked_and_notallones_logical(i32 %A) {
75 ; CHECK-LABEL: @masked_and_notallones_logical(
76 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
77 ; CHECK-NEXT: [[TST1:%.*]] = icmp ne i32 [[MASK1]], 7
78 ; CHECK-NEXT: ret i1 [[TST1]]
80 %mask1 = and i32 %A, 7
81 %tst1 = icmp ne i32 %mask1, 7
82 %mask2 = and i32 %A, 39
83 %tst2 = icmp ne i32 %mask2, 39
84 %res = select i1 %tst1, i1 %tst2, i1 false
88 define i1 @masked_or_allones(i32 %A) {
89 ; CHECK-LABEL: @masked_or_allones(
90 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
91 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 7
92 ; CHECK-NEXT: ret i1 [[TST1]]
94 %mask1 = and i32 %A, 7
95 %tst1 = icmp eq i32 %mask1, 7
96 %mask2 = and i32 %A, 39
97 %tst2 = icmp eq i32 %mask2, 39
98 %res = or i1 %tst1, %tst2
102 define i1 @masked_or_allones_logical(i32 %A) {
103 ; CHECK-LABEL: @masked_or_allones_logical(
104 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 7
105 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 7
106 ; CHECK-NEXT: ret i1 [[TST1]]
108 %mask1 = and i32 %A, 7
109 %tst1 = icmp eq i32 %mask1, 7
110 %mask2 = and i32 %A, 39
111 %tst2 = icmp eq i32 %mask2, 39
112 %res = select i1 %tst1, i1 true, i1 %tst2
116 define i1 @masked_and_notA(i32 %A) {
117 ; CHECK-LABEL: @masked_and_notA(
118 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A:%.*]], 78
119 ; CHECK-NEXT: [[TST2:%.*]] = icmp ne i32 [[MASK2]], [[A]]
120 ; CHECK-NEXT: ret i1 [[TST2]]
122 %mask1 = and i32 %A, 14
123 %tst1 = icmp ne i32 %mask1, %A
124 %mask2 = and i32 %A, 78
125 %tst2 = icmp ne i32 %mask2, %A
126 %res = and i1 %tst1, %tst2
130 define i1 @masked_and_notA_logical(i32 %A) {
131 ; CHECK-LABEL: @masked_and_notA_logical(
132 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A:%.*]], 78
133 ; CHECK-NEXT: [[TST2:%.*]] = icmp ne i32 [[MASK2]], [[A]]
134 ; CHECK-NEXT: ret i1 [[TST2]]
136 %mask1 = and i32 %A, 14
137 %tst1 = icmp ne i32 %mask1, %A
138 %mask2 = and i32 %A, 78
139 %tst2 = icmp ne i32 %mask2, %A
140 %res = select i1 %tst1, i1 %tst2, i1 false
144 define i1 @masked_and_notA_slightly_optimized(i32 %A) {
145 ; CHECK-LABEL: @masked_and_notA_slightly_optimized(
146 ; CHECK-NEXT: [[T0:%.*]] = icmp ugt i32 [[A:%.*]], 7
147 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
148 ; CHECK-NEXT: [[TST2:%.*]] = icmp ne i32 [[MASK2]], [[A]]
149 ; CHECK-NEXT: [[RES:%.*]] = and i1 [[T0]], [[TST2]]
150 ; CHECK-NEXT: ret i1 [[RES]]
152 %t0 = icmp uge i32 %A, 8
153 %mask2 = and i32 %A, 39
154 %tst2 = icmp ne i32 %mask2, %A
155 %res = and i1 %t0, %tst2
159 define i1 @masked_and_notA_slightly_optimized_logical(i32 %A) {
160 ; CHECK-LABEL: @masked_and_notA_slightly_optimized_logical(
161 ; CHECK-NEXT: [[T0:%.*]] = icmp ugt i32 [[A:%.*]], 7
162 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
163 ; CHECK-NEXT: [[TST2:%.*]] = icmp ne i32 [[MASK2]], [[A]]
164 ; CHECK-NEXT: [[RES:%.*]] = and i1 [[T0]], [[TST2]]
165 ; CHECK-NEXT: ret i1 [[RES]]
167 %t0 = icmp uge i32 %A, 8
168 %mask2 = and i32 %A, 39
169 %tst2 = icmp ne i32 %mask2, %A
170 %res = select i1 %t0, i1 %tst2, i1 false
174 define i1 @masked_or_A(i32 %A) {
175 ; CHECK-LABEL: @masked_or_A(
176 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A:%.*]], 78
177 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], [[A]]
178 ; CHECK-NEXT: ret i1 [[TST2]]
180 %mask1 = and i32 %A, 14
181 %tst1 = icmp eq i32 %mask1, %A
182 %mask2 = and i32 %A, 78
183 %tst2 = icmp eq i32 %mask2, %A
184 %res = or i1 %tst1, %tst2
188 define i1 @masked_or_A_logical(i32 %A) {
189 ; CHECK-LABEL: @masked_or_A_logical(
190 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A:%.*]], 78
191 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], [[A]]
192 ; CHECK-NEXT: ret i1 [[TST2]]
194 %mask1 = and i32 %A, 14
195 %tst1 = icmp eq i32 %mask1, %A
196 %mask2 = and i32 %A, 78
197 %tst2 = icmp eq i32 %mask2, %A
198 %res = select i1 %tst1, i1 true, i1 %tst2
202 define i1 @masked_or_A_slightly_optimized(i32 %A) {
203 ; CHECK-LABEL: @masked_or_A_slightly_optimized(
204 ; CHECK-NEXT: [[T0:%.*]] = icmp ult i32 [[A:%.*]], 8
205 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
206 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], [[A]]
207 ; CHECK-NEXT: [[RES:%.*]] = or i1 [[T0]], [[TST2]]
208 ; CHECK-NEXT: ret i1 [[RES]]
210 %t0 = icmp ult i32 %A, 8
211 %mask2 = and i32 %A, 39
212 %tst2 = icmp eq i32 %mask2, %A
213 %res = or i1 %t0, %tst2
217 define i1 @masked_or_A_slightly_optimized_logical(i32 %A) {
218 ; CHECK-LABEL: @masked_or_A_slightly_optimized_logical(
219 ; CHECK-NEXT: [[T0:%.*]] = icmp ult i32 [[A:%.*]], 8
220 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
221 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], [[A]]
222 ; CHECK-NEXT: [[RES:%.*]] = or i1 [[T0]], [[TST2]]
223 ; CHECK-NEXT: ret i1 [[RES]]
225 %t0 = icmp ult i32 %A, 8
226 %mask2 = and i32 %A, 39
227 %tst2 = icmp eq i32 %mask2, %A
228 %res = select i1 %t0, i1 true, i1 %tst2
232 define i1 @masked_or_allzeroes_notoptimised(i32 %A) {
233 ; CHECK-LABEL: @masked_or_allzeroes_notoptimised(
234 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 15
235 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 0
236 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
237 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], 0
238 ; CHECK-NEXT: [[RES:%.*]] = or i1 [[TST1]], [[TST2]]
239 ; CHECK-NEXT: ret i1 [[RES]]
241 %mask1 = and i32 %A, 15
242 %tst1 = icmp eq i32 %mask1, 0
243 %mask2 = and i32 %A, 39
244 %tst2 = icmp eq i32 %mask2, 0
245 %res = or i1 %tst1, %tst2
249 define i1 @masked_or_allzeroes_notoptimised_logical(i32 %A) {
250 ; CHECK-LABEL: @masked_or_allzeroes_notoptimised_logical(
251 ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[A:%.*]], 15
252 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASK1]], 0
253 ; CHECK-NEXT: [[MASK2:%.*]] = and i32 [[A]], 39
254 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASK2]], 0
255 ; CHECK-NEXT: [[RES:%.*]] = or i1 [[TST1]], [[TST2]]
256 ; CHECK-NEXT: ret i1 [[RES]]
258 %mask1 = and i32 %A, 15
259 %tst1 = icmp eq i32 %mask1, 0
260 %mask2 = and i32 %A, 39
261 %tst2 = icmp eq i32 %mask2, 0
262 %res = select i1 %tst1, i1 true, i1 %tst2
266 define i1 @nomask_lhs(i32 %in) {
267 ; CHECK-LABEL: @nomask_lhs(
268 ; CHECK-NEXT: [[MASKED:%.*]] = and i32 [[IN:%.*]], 1
269 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASKED]], 0
270 ; CHECK-NEXT: ret i1 [[TST2]]
272 %tst1 = icmp eq i32 %in, 0
273 %masked = and i32 %in, 1
274 %tst2 = icmp eq i32 %masked, 0
275 %val = or i1 %tst1, %tst2
279 define i1 @nomask_lhs_logical(i32 %in) {
280 ; CHECK-LABEL: @nomask_lhs_logical(
281 ; CHECK-NEXT: [[MASKED:%.*]] = and i32 [[IN:%.*]], 1
282 ; CHECK-NEXT: [[TST2:%.*]] = icmp eq i32 [[MASKED]], 0
283 ; CHECK-NEXT: ret i1 [[TST2]]
285 %tst1 = icmp eq i32 %in, 0
286 %masked = and i32 %in, 1
287 %tst2 = icmp eq i32 %masked, 0
288 %val = select i1 %tst1, i1 true, i1 %tst2
292 define i1 @nomask_rhs(i32 %in) {
293 ; CHECK-LABEL: @nomask_rhs(
294 ; CHECK-NEXT: [[MASKED:%.*]] = and i32 [[IN:%.*]], 1
295 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASKED]], 0
296 ; CHECK-NEXT: ret i1 [[TST1]]
298 %masked = and i32 %in, 1
299 %tst1 = icmp eq i32 %masked, 0
300 %tst2 = icmp eq i32 %in, 0
301 %val = or i1 %tst1, %tst2
305 define i1 @nomask_rhs_logical(i32 %in) {
306 ; CHECK-LABEL: @nomask_rhs_logical(
307 ; CHECK-NEXT: [[MASKED:%.*]] = and i32 [[IN:%.*]], 1
308 ; CHECK-NEXT: [[TST1:%.*]] = icmp eq i32 [[MASKED]], 0
309 ; CHECK-NEXT: ret i1 [[TST1]]
311 %masked = and i32 %in, 1
312 %tst1 = icmp eq i32 %masked, 0
313 %tst2 = icmp eq i32 %in, 0
314 %val = select i1 %tst1, i1 true, i1 %tst2
318 ; TODO: This test simplifies to a constant, so the functionality and test could be in InstSimplify.
320 define i1 @fold_mask_cmps_to_false(i32 %x) {
321 ; CHECK-LABEL: @fold_mask_cmps_to_false(
322 ; CHECK-NEXT: ret i1 false
324 %t1 = and i32 %x, 2147483647
325 %t2 = icmp eq i32 %t1, 0
326 %t3 = icmp eq i32 %x, 2147483647
327 %t4 = and i1 %t3, %t2
331 define i1 @fold_mask_cmps_to_false_logical(i32 %x) {
332 ; CHECK-LABEL: @fold_mask_cmps_to_false_logical(
333 ; CHECK-NEXT: ret i1 false
335 %t1 = and i32 %x, 2147483647
336 %t2 = icmp eq i32 %t1, 0
337 %t3 = icmp eq i32 %x, 2147483647
338 %t4 = select i1 %t3, i1 %t2, i1 false
342 ; TODO: This test simplifies to a constant, so the functionality and test could be in InstSimplify.
344 define i1 @fold_mask_cmps_to_true(i32 %x) {
345 ; CHECK-LABEL: @fold_mask_cmps_to_true(
346 ; CHECK-NEXT: ret i1 true
348 %t1 = and i32 %x, 2147483647
349 %t2 = icmp ne i32 %t1, 0
350 %t3 = icmp ne i32 %x, 2147483647
355 define i1 @fold_mask_cmps_to_true_logical(i32 %x) {
356 ; CHECK-LABEL: @fold_mask_cmps_to_true_logical(
357 ; CHECK-NEXT: ret i1 true
359 %t1 = and i32 %x, 2147483647
360 %t2 = icmp ne i32 %t1, 0
361 %t3 = icmp ne i32 %x, 2147483647
362 %t4 = select i1 %t3, i1 true, i1 %t2
366 ; PR32401 - https://bugs.llvm.org/show_bug.cgi?id=32401
368 define i1 @cmpeq_bitwise(i8 %a, i8 %b, i8 %c, i8 %d) {
369 ; CHECK-LABEL: @cmpeq_bitwise(
370 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]
371 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i8 [[C:%.*]], [[D:%.*]]
372 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP1]], [[TMP2]]
373 ; CHECK-NEXT: ret i1 [[CMP]]
375 %xor1 = xor i8 %a, %b
376 %xor2 = xor i8 %c, %d
377 %or = or i8 %xor1, %xor2
378 %cmp = icmp eq i8 %or, 0
382 define <2 x i1> @cmpne_bitwise(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c, <2 x i64> %d) {
383 ; CHECK-LABEL: @cmpne_bitwise(
384 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i64> [[A:%.*]], [[B:%.*]]
385 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne <2 x i64> [[C:%.*]], [[D:%.*]]
386 ; CHECK-NEXT: [[CMP:%.*]] = or <2 x i1> [[TMP1]], [[TMP2]]
387 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
389 %xor1 = xor <2 x i64> %a, %b
390 %xor2 = xor <2 x i64> %c, %d
391 %or = or <2 x i64> %xor1, %xor2
392 %cmp = icmp ne <2 x i64> %or, zeroinitializer
396 ; ((X & 12) != 0 & (X & 3) == 1) -> no change
397 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_0(i32 %x) {
398 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_0(
399 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
400 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
401 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
402 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
403 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
404 ; CHECK-NEXT: ret i1 [[T5]]
407 %t2 = icmp ne i32 %t1, 0
409 %t4 = icmp eq i32 %t3, 1
410 %t5 = and i1 %t2, %t4
414 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_0_logical(i32 %x) {
415 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_0_logical(
416 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
417 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
418 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
419 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
420 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
421 ; CHECK-NEXT: ret i1 [[T5]]
424 %t2 = icmp ne i32 %t1, 0
426 %t4 = icmp eq i32 %t3, 1
427 %t5 = select i1 %t2, i1 %t4, i1 false
431 ; ((X & 12) != 0 & (X & 7) == 1) -> (X & 15) == 9
432 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_1(i32 %x) {
433 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_1(
434 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
435 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 9
436 ; CHECK-NEXT: ret i1 [[TMP2]]
439 %t2 = icmp ne i32 %t1, 0
441 %t4 = icmp eq i32 %t3, 1
442 %t5 = and i1 %t2, %t4
446 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_1_logical(i32 %x) {
447 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_1_logical(
448 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
449 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 9
450 ; CHECK-NEXT: ret i1 [[TMP2]]
453 %t2 = icmp ne i32 %t1, 0
455 %t4 = icmp eq i32 %t3, 1
456 %t5 = select i1 %t2, i1 %t4, i1 false
460 ; ((X & 14) != 0 & (X & 3) == 1) -> no change
461 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_1b(i32 %x) {
462 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_1b(
463 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
464 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
465 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
466 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
467 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
468 ; CHECK-NEXT: ret i1 [[T5]]
471 %t2 = icmp ne i32 %t1, 0
473 %t4 = icmp eq i32 %t3, 1
474 %t5 = and i1 %t2, %t4
478 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_1b_logical(i32 %x) {
479 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_1b_logical(
480 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
481 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
482 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
483 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
484 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
485 ; CHECK-NEXT: ret i1 [[T5]]
488 %t2 = icmp ne i32 %t1, 0
490 %t4 = icmp eq i32 %t3, 1
491 %t5 = select i1 %t2, i1 %t4, i1 false
495 ; ((X & 3) != 0 & (X & 7) == 0) -> false
496 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_2(i32 %x) {
497 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_2(
498 ; CHECK-NEXT: ret i1 false
501 %t2 = icmp ne i32 %t1, 0
503 %t4 = icmp eq i32 %t3, 0
504 %t5 = and i1 %t2, %t4
508 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_2_logical(i32 %x) {
509 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_2_logical(
510 ; CHECK-NEXT: ret i1 false
513 %t2 = icmp ne i32 %t1, 0
515 %t4 = icmp eq i32 %t3, 0
516 %t5 = select i1 %t2, i1 %t4, i1 false
520 ; ((X & 15) != 0 & (X & 7) == 0) -> (X & 15) == 8
521 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_3(i32 %x) {
522 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_3(
523 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
524 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 8
525 ; CHECK-NEXT: ret i1 [[TMP2]]
528 %t2 = icmp ne i32 %t1, 0
530 %t4 = icmp eq i32 %t3, 0
531 %t5 = and i1 %t2, %t4
535 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_3_logical(i32 %x) {
536 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_3_logical(
537 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
538 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 8
539 ; CHECK-NEXT: ret i1 [[TMP2]]
542 %t2 = icmp ne i32 %t1, 0
544 %t4 = icmp eq i32 %t3, 0
545 %t5 = select i1 %t2, i1 %t4, i1 false
549 ; ((X & 15) != 0 & (X & 3) == 0) -> no change
550 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_3b(i32 %x) {
551 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_3b(
552 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
553 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
554 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
555 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 0
556 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
557 ; CHECK-NEXT: ret i1 [[T5]]
560 %t2 = icmp ne i32 %t1, 0
562 %t4 = icmp eq i32 %t3, 0
563 %t5 = and i1 %t2, %t4
567 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_3b_logical(i32 %x) {
568 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_3b_logical(
569 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
570 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
571 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
572 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 0
573 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T2]], [[T4]]
574 ; CHECK-NEXT: ret i1 [[T5]]
577 %t2 = icmp ne i32 %t1, 0
579 %t4 = icmp eq i32 %t3, 0
580 %t5 = select i1 %t2, i1 %t4, i1 false
584 ; ((X & 255) != 0 & (X & 15) == 8) -> (X & 15) == 8
585 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_4(i32 %x) {
586 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_4(
587 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
588 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
589 ; CHECK-NEXT: ret i1 [[T4]]
591 %t1 = and i32 %x, 255
592 %t2 = icmp ne i32 %t1, 0
594 %t4 = icmp eq i32 %t3, 8
595 %t5 = and i1 %t2, %t4
599 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_4_logical(i32 %x) {
600 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_4_logical(
601 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
602 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
603 ; CHECK-NEXT: ret i1 [[T4]]
605 %t1 = and i32 %x, 255
606 %t2 = icmp ne i32 %t1, 0
608 %t4 = icmp eq i32 %t3, 8
609 %t5 = select i1 %t2, i1 %t4, i1 false
613 ; ((X & 15) != 0 & (X & 15) == 8) -> (X & 15) == 8
614 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_5(i32 %x) {
615 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_5(
616 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
617 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
618 ; CHECK-NEXT: ret i1 [[T4]]
621 %t2 = icmp ne i32 %t1, 0
623 %t4 = icmp eq i32 %t3, 8
624 %t5 = and i1 %t2, %t4
628 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_5_logical(i32 %x) {
629 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_5_logical(
630 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
631 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
632 ; CHECK-NEXT: ret i1 [[T4]]
635 %t2 = icmp ne i32 %t1, 0
637 %t4 = icmp eq i32 %t3, 8
638 %t5 = select i1 %t2, i1 %t4, i1 false
642 ; ((X & 12) != 0 & (X & 15) == 8) -> (X & 15) == 8
643 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_6(i32 %x) {
644 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_6(
645 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
646 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
647 ; CHECK-NEXT: ret i1 [[T4]]
650 %t2 = icmp ne i32 %t1, 0
652 %t4 = icmp eq i32 %t3, 8
653 %t5 = and i1 %t2, %t4
657 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_6_logical(i32 %x) {
658 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_6_logical(
659 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
660 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
661 ; CHECK-NEXT: ret i1 [[T4]]
664 %t2 = icmp ne i32 %t1, 0
666 %t4 = icmp eq i32 %t3, 8
667 %t5 = select i1 %t2, i1 %t4, i1 false
671 ; ((X & 7) != 0 & (X & 15) == 8) -> false
672 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_7(i32 %x) {
673 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_7(
674 ; CHECK-NEXT: ret i1 false
677 %t2 = icmp ne i32 %t1, 0
679 %t4 = icmp eq i32 %t3, 8
680 %t5 = and i1 %t2, %t4
684 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_7_logical(i32 %x) {
685 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_7_logical(
686 ; CHECK-NEXT: ret i1 false
689 %t2 = icmp ne i32 %t1, 0
691 %t4 = icmp eq i32 %t3, 8
692 %t5 = select i1 %t2, i1 %t4, i1 false
696 ; ((X & 6) != 0 & (X & 15) == 8) -> false
697 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_7b(i32 %x) {
698 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_7b(
699 ; CHECK-NEXT: ret i1 false
702 %t2 = icmp ne i32 %t1, 0
704 %t4 = icmp eq i32 %t3, 8
705 %t5 = and i1 %t2, %t4
709 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_7b_logical(i32 %x) {
710 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_7b_logical(
711 ; CHECK-NEXT: ret i1 false
714 %t2 = icmp ne i32 %t1, 0
716 %t4 = icmp eq i32 %t3, 8
717 %t5 = select i1 %t2, i1 %t4, i1 false
721 ; ((X & 12) == 0 | (X & 3) != 1) -> !((X & 12) != 0 & (X & 3) == 1)) ->
723 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_0(i32 %x) {
724 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_0(
725 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
726 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
727 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
728 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
729 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
730 ; CHECK-NEXT: ret i1 [[T5]]
733 %t2 = icmp eq i32 %t1, 0
735 %t4 = icmp ne i32 %t3, 1
740 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_0_logical(i32 %x) {
741 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_0_logical(
742 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
743 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
744 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
745 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
746 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
747 ; CHECK-NEXT: ret i1 [[T5]]
750 %t2 = icmp eq i32 %t1, 0
752 %t4 = icmp ne i32 %t3, 1
753 %t5 = select i1 %t2, i1 true, i1 %t4
757 ; ((X & 12) == 0 | (X & 7) != 1) -> !((X & 12) != 0 & (X & 7) == 1) ->
758 ; !((X & 15) == 9) -> (X & 15) != 9
759 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_1(i32 %x) {
760 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_1(
761 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
762 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 9
763 ; CHECK-NEXT: ret i1 [[TMP2]]
766 %t2 = icmp eq i32 %t1, 0
768 %t4 = icmp ne i32 %t3, 1
773 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_1_logical(i32 %x) {
774 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_1_logical(
775 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
776 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 9
777 ; CHECK-NEXT: ret i1 [[TMP2]]
780 %t2 = icmp eq i32 %t1, 0
782 %t4 = icmp ne i32 %t3, 1
783 %t5 = select i1 %t2, i1 true, i1 %t4
787 ; ((X & 14) == 0 | (X & 3) != 1) -> !((X & 14) != 0 & (X & 3) == 1) ->
789 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b(i32 %x) {
790 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b(
791 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
792 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
793 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
794 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
795 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
796 ; CHECK-NEXT: ret i1 [[T5]]
799 %t2 = icmp eq i32 %t1, 0
801 %t4 = icmp ne i32 %t3, 1
806 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b_logical(i32 %x) {
807 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_1b_logical(
808 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
809 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
810 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
811 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
812 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
813 ; CHECK-NEXT: ret i1 [[T5]]
816 %t2 = icmp eq i32 %t1, 0
818 %t4 = icmp ne i32 %t3, 1
819 %t5 = select i1 %t2, i1 true, i1 %t4
823 ; ((X & 3) == 0 | (X & 7) != 0) -> !((X & 3) != 0 & (X & 7) == 0) ->
825 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_2(i32 %x) {
826 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_2(
827 ; CHECK-NEXT: ret i1 true
830 %t2 = icmp eq i32 %t1, 0
832 %t4 = icmp ne i32 %t3, 0
837 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_2_logical(i32 %x) {
838 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_2_logical(
839 ; CHECK-NEXT: ret i1 true
842 %t2 = icmp eq i32 %t1, 0
844 %t4 = icmp ne i32 %t3, 0
845 %t5 = select i1 %t2, i1 true, i1 %t4
849 ; ((X & 15) == 0 | (X & 7) != 0) -> !((X & 15) != 0 & (X & 7) == 0) ->
850 ; !((X & 15) == 8) -> (X & 15) != 8
851 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_3(i32 %x) {
852 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_3(
853 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
854 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 8
855 ; CHECK-NEXT: ret i1 [[TMP2]]
858 %t2 = icmp eq i32 %t1, 0
860 %t4 = icmp ne i32 %t3, 0
865 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_3_logical(i32 %x) {
866 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_3_logical(
867 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
868 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 8
869 ; CHECK-NEXT: ret i1 [[TMP2]]
872 %t2 = icmp eq i32 %t1, 0
874 %t4 = icmp ne i32 %t3, 0
875 %t5 = select i1 %t2, i1 true, i1 %t4
879 ; ((X & 15) == 0 | (X & 3) != 0) -> !((X & 15) != 0 & (X & 3) == 0) ->
881 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b(i32 %x) {
882 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b(
883 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
884 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
885 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
886 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
887 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
888 ; CHECK-NEXT: ret i1 [[T5]]
891 %t2 = icmp eq i32 %t1, 0
893 %t4 = icmp ne i32 %t3, 0
898 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b_logical(i32 %x) {
899 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_3b_logical(
900 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
901 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
902 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
903 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
904 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T2]], [[T4]]
905 ; CHECK-NEXT: ret i1 [[T5]]
908 %t2 = icmp eq i32 %t1, 0
910 %t4 = icmp ne i32 %t3, 0
911 %t5 = select i1 %t2, i1 true, i1 %t4
915 ; ((X & 255) == 0 | (X & 15) != 8) -> !(((X & 255) != 0 & (X & 15) == 8)) ->
916 ; !((X & 15) == 8) -> ((X & 15) != 8)
917 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_4(i32 %x) {
918 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_4(
919 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
920 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
921 ; CHECK-NEXT: ret i1 [[T4]]
923 %t1 = and i32 %x, 255
924 %t2 = icmp eq i32 %t1, 0
926 %t4 = icmp ne i32 %t3, 8
931 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_4_logical(i32 %x) {
932 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_4_logical(
933 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
934 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
935 ; CHECK-NEXT: ret i1 [[T4]]
937 %t1 = and i32 %x, 255
938 %t2 = icmp eq i32 %t1, 0
940 %t4 = icmp ne i32 %t3, 8
941 %t5 = select i1 %t2, i1 true, i1 %t4
945 ; ((X & 15) == 0 | (X & 15) != 8) -> !(((X & 15) != 0 & (X & 15) == 8)) ->
946 ; !((X & 15) == 8) -> ((X & 15) != 8)
947 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_5(i32 %x) {
948 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_5(
949 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
950 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
951 ; CHECK-NEXT: ret i1 [[T4]]
954 %t2 = icmp eq i32 %t1, 0
956 %t4 = icmp ne i32 %t3, 8
961 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_5_logical(i32 %x) {
962 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_5_logical(
963 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
964 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
965 ; CHECK-NEXT: ret i1 [[T4]]
968 %t2 = icmp eq i32 %t1, 0
970 %t4 = icmp ne i32 %t3, 8
971 %t5 = select i1 %t2, i1 true, i1 %t4
975 ; ((X & 12) == 0 | (X & 15) != 8) -> !(((X & 12) != 0 & (X & 15) == 8)) ->
976 ; !((X & 15) == 8) -> ((X & 15) != 8
977 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_6(i32 %x) {
978 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_6(
979 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
980 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
981 ; CHECK-NEXT: ret i1 [[T4]]
984 %t2 = icmp eq i32 %t1, 0
986 %t4 = icmp ne i32 %t3, 8
991 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_6_logical(i32 %x) {
992 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_6_logical(
993 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
994 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
995 ; CHECK-NEXT: ret i1 [[T4]]
998 %t2 = icmp eq i32 %t1, 0
1000 %t4 = icmp ne i32 %t3, 8
1001 %t5 = select i1 %t2, i1 true, i1 %t4
1005 ; ((X & 7) == 0 | (X & 15) != 8) -> !(((X & 7) != 0 & (X & 15) == 8)) ->
1007 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_7(i32 %x) {
1008 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_7(
1009 ; CHECK-NEXT: ret i1 true
1012 %t2 = icmp eq i32 %t1, 0
1013 %t3 = and i32 %x, 15
1014 %t4 = icmp ne i32 %t3, 8
1015 %t5 = or i1 %t2, %t4
1019 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_7_logical(i32 %x) {
1020 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_7_logical(
1021 ; CHECK-NEXT: ret i1 true
1024 %t2 = icmp eq i32 %t1, 0
1025 %t3 = and i32 %x, 15
1026 %t4 = icmp ne i32 %t3, 8
1027 %t5 = select i1 %t2, i1 true, i1 %t4
1031 ; ((X & 6) == 0 | (X & 15) != 8) -> !(((X & 6) != 0 & (X & 15) == 8)) ->
1033 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b(i32 %x) {
1034 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b(
1035 ; CHECK-NEXT: ret i1 true
1038 %t2 = icmp eq i32 %t1, 0
1039 %t3 = and i32 %x, 15
1040 %t4 = icmp ne i32 %t3, 8
1041 %t5 = or i1 %t2, %t4
1045 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b_logical(i32 %x) {
1046 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_7b_logical(
1047 ; CHECK-NEXT: ret i1 true
1050 %t2 = icmp eq i32 %t1, 0
1051 %t3 = and i32 %x, 15
1052 %t4 = icmp ne i32 %t3, 8
1053 %t5 = select i1 %t2, i1 true, i1 %t4
1058 ; ((X & 12) != 0 & (X & 3) == 1) -> no change
1059 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0(i32 %x) {
1060 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0(
1061 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
1062 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1063 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1064 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
1065 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1066 ; CHECK-NEXT: ret i1 [[T5]]
1068 %t1 = and i32 %x, 12
1069 %t2 = icmp ne i32 %t1, 0
1071 %t4 = icmp eq i32 %t3, 1
1072 %t5 = and i1 %t4, %t2
1076 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0_logical(i32 %x) {
1077 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_0_logical(
1078 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
1079 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1080 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1081 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
1082 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1083 ; CHECK-NEXT: ret i1 [[T5]]
1085 %t1 = and i32 %x, 12
1086 %t2 = icmp ne i32 %t1, 0
1088 %t4 = icmp eq i32 %t3, 1
1089 %t5 = select i1 %t4, i1 %t2, i1 false
1093 ; ((X & 12) != 0 & (X & 7) == 1) -> (X & 15) == 9
1094 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1(i32 %x) {
1095 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1(
1096 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1097 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 9
1098 ; CHECK-NEXT: ret i1 [[TMP2]]
1100 %t1 = and i32 %x, 12
1101 %t2 = icmp ne i32 %t1, 0
1103 %t4 = icmp eq i32 %t3, 1
1104 %t5 = and i1 %t4, %t2
1108 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1_logical(i32 %x) {
1109 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1_logical(
1110 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1111 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 9
1112 ; CHECK-NEXT: ret i1 [[TMP2]]
1114 %t1 = and i32 %x, 12
1115 %t2 = icmp ne i32 %t1, 0
1117 %t4 = icmp eq i32 %t3, 1
1118 %t5 = select i1 %t4, i1 %t2, i1 false
1122 ; ((X & 14) != 0 & (X & 3) == 1) -> no change
1123 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b(i32 %x) {
1124 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b(
1125 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
1126 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1127 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1128 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
1129 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1130 ; CHECK-NEXT: ret i1 [[T5]]
1132 %t1 = and i32 %x, 14
1133 %t2 = icmp ne i32 %t1, 0
1135 %t4 = icmp eq i32 %t3, 1
1136 %t5 = and i1 %t4, %t2
1140 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b_logical(i32 %x) {
1141 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_1b_logical(
1142 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
1143 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1144 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1145 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 1
1146 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1147 ; CHECK-NEXT: ret i1 [[T5]]
1149 %t1 = and i32 %x, 14
1150 %t2 = icmp ne i32 %t1, 0
1152 %t4 = icmp eq i32 %t3, 1
1153 %t5 = select i1 %t4, i1 %t2, i1 false
1157 ; ((X & 3) != 0 & (X & 7) == 0) -> false
1158 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2(i32 %x) {
1159 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2(
1160 ; CHECK-NEXT: ret i1 false
1163 %t2 = icmp ne i32 %t1, 0
1165 %t4 = icmp eq i32 %t3, 0
1166 %t5 = and i1 %t4, %t2
1170 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2_logical(i32 %x) {
1171 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_2_logical(
1172 ; CHECK-NEXT: ret i1 false
1175 %t2 = icmp ne i32 %t1, 0
1177 %t4 = icmp eq i32 %t3, 0
1178 %t5 = select i1 %t4, i1 %t2, i1 false
1182 ; ((X & 15) != 0 & (X & 7) == 0) -> (X & 15) == 8
1183 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3(i32 %x) {
1184 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3(
1185 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1186 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 8
1187 ; CHECK-NEXT: ret i1 [[TMP2]]
1189 %t1 = and i32 %x, 15
1190 %t2 = icmp ne i32 %t1, 0
1192 %t4 = icmp eq i32 %t3, 0
1193 %t5 = and i1 %t4, %t2
1197 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3_logical(i32 %x) {
1198 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3_logical(
1199 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1200 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 8
1201 ; CHECK-NEXT: ret i1 [[TMP2]]
1203 %t1 = and i32 %x, 15
1204 %t2 = icmp ne i32 %t1, 0
1206 %t4 = icmp eq i32 %t3, 0
1207 %t5 = select i1 %t4, i1 %t2, i1 false
1211 ; ((X & 15) != 0 & (X & 3) == 0) -> no change
1212 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b(i32 %x) {
1213 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b(
1214 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
1215 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1216 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1217 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 0
1218 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1219 ; CHECK-NEXT: ret i1 [[T5]]
1221 %t1 = and i32 %x, 15
1222 %t2 = icmp ne i32 %t1, 0
1224 %t4 = icmp eq i32 %t3, 0
1225 %t5 = and i1 %t4, %t2
1229 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b_logical(i32 %x) {
1230 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_3b_logical(
1231 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
1232 ; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
1233 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1234 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 0
1235 ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T4]], [[T2]]
1236 ; CHECK-NEXT: ret i1 [[T5]]
1238 %t1 = and i32 %x, 15
1239 %t2 = icmp ne i32 %t1, 0
1241 %t4 = icmp eq i32 %t3, 0
1242 %t5 = select i1 %t4, i1 %t2, i1 false
1246 ; ((X & 255) != 0 & (X & 15) == 8) -> (X & 15) == 8
1247 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4(i32 %x) {
1248 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4(
1249 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1250 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1251 ; CHECK-NEXT: ret i1 [[T4]]
1253 %t1 = and i32 %x, 255
1254 %t2 = icmp ne i32 %t1, 0
1255 %t3 = and i32 %x, 15
1256 %t4 = icmp eq i32 %t3, 8
1257 %t5 = and i1 %t4, %t2
1261 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4_logical(i32 %x) {
1262 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_4_logical(
1263 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1264 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1265 ; CHECK-NEXT: ret i1 [[T4]]
1267 %t1 = and i32 %x, 255
1268 %t2 = icmp ne i32 %t1, 0
1269 %t3 = and i32 %x, 15
1270 %t4 = icmp eq i32 %t3, 8
1271 %t5 = select i1 %t4, i1 %t2, i1 false
1275 ; ((X & 15) != 0 & (X & 15) == 8) -> (X & 15) == 8
1276 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5(i32 %x) {
1277 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5(
1278 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1279 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1280 ; CHECK-NEXT: ret i1 [[T4]]
1282 %t1 = and i32 %x, 15
1283 %t2 = icmp ne i32 %t1, 0
1284 %t3 = and i32 %x, 15
1285 %t4 = icmp eq i32 %t3, 8
1286 %t5 = and i1 %t4, %t2
1290 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5_logical(i32 %x) {
1291 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_5_logical(
1292 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1293 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1294 ; CHECK-NEXT: ret i1 [[T4]]
1296 %t1 = and i32 %x, 15
1297 %t2 = icmp ne i32 %t1, 0
1298 %t3 = and i32 %x, 15
1299 %t4 = icmp eq i32 %t3, 8
1300 %t5 = select i1 %t4, i1 %t2, i1 false
1304 ; ((X & 12) != 0 & (X & 15) == 8) -> (X & 15) == 8
1305 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6(i32 %x) {
1306 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6(
1307 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1308 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1309 ; CHECK-NEXT: ret i1 [[T4]]
1311 %t1 = and i32 %x, 12
1312 %t2 = icmp ne i32 %t1, 0
1313 %t3 = and i32 %x, 15
1314 %t4 = icmp eq i32 %t3, 8
1315 %t5 = and i1 %t4, %t2
1319 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6_logical(i32 %x) {
1320 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_6_logical(
1321 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1322 ; CHECK-NEXT: [[T4:%.*]] = icmp eq i32 [[T3]], 8
1323 ; CHECK-NEXT: ret i1 [[T4]]
1325 %t1 = and i32 %x, 12
1326 %t2 = icmp ne i32 %t1, 0
1327 %t3 = and i32 %x, 15
1328 %t4 = icmp eq i32 %t3, 8
1329 %t5 = select i1 %t4, i1 %t2, i1 false
1333 ; ((X & 7) != 0 & (X & 15) == 8) -> false
1334 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7(i32 %x) {
1335 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7(
1336 ; CHECK-NEXT: ret i1 false
1339 %t2 = icmp ne i32 %t1, 0
1340 %t3 = and i32 %x, 15
1341 %t4 = icmp eq i32 %t3, 8
1342 %t5 = and i1 %t4, %t2
1346 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7_logical(i32 %x) {
1347 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7_logical(
1348 ; CHECK-NEXT: ret i1 false
1351 %t2 = icmp ne i32 %t1, 0
1352 %t3 = and i32 %x, 15
1353 %t4 = icmp eq i32 %t3, 8
1354 %t5 = select i1 %t4, i1 %t2, i1 false
1358 ; ((X & 6) != 0 & (X & 15) == 8) -> false
1359 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b(i32 %x) {
1360 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b(
1361 ; CHECK-NEXT: ret i1 false
1364 %t2 = icmp ne i32 %t1, 0
1365 %t3 = and i32 %x, 15
1366 %t4 = icmp eq i32 %t3, 8
1367 %t5 = and i1 %t4, %t2
1371 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b_logical(i32 %x) {
1372 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_swapped_7b_logical(
1373 ; CHECK-NEXT: ret i1 false
1376 %t2 = icmp ne i32 %t1, 0
1377 %t3 = and i32 %x, 15
1378 %t4 = icmp eq i32 %t3, 8
1379 %t5 = select i1 %t4, i1 %t2, i1 false
1383 ; ((X & 12) == 0 | (X & 3) != 1) -> !((X & 12) != 0 & (X & 3) == 1)) ->
1385 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0(i32 %x) {
1386 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0(
1387 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
1388 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1389 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1390 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
1391 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1392 ; CHECK-NEXT: ret i1 [[T5]]
1394 %t1 = and i32 %x, 12
1395 %t2 = icmp eq i32 %t1, 0
1397 %t4 = icmp ne i32 %t3, 1
1398 %t5 = or i1 %t4, %t2
1402 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0_logical(i32 %x) {
1403 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_0_logical(
1404 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 12
1405 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1406 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1407 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
1408 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1409 ; CHECK-NEXT: ret i1 [[T5]]
1411 %t1 = and i32 %x, 12
1412 %t2 = icmp eq i32 %t1, 0
1414 %t4 = icmp ne i32 %t3, 1
1415 %t5 = select i1 %t4, i1 true, i1 %t2
1419 ; ((X & 12) == 0 | (X & 7) != 1) -> !((X & 12) != 0 & (X & 7) == 1) ->
1420 ; !((X & 15) == 9) -> (X & 15) != 9
1421 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1(i32 %x) {
1422 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1(
1423 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1424 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 9
1425 ; CHECK-NEXT: ret i1 [[TMP2]]
1427 %t1 = and i32 %x, 12
1428 %t2 = icmp eq i32 %t1, 0
1430 %t4 = icmp ne i32 %t3, 1
1431 %t5 = or i1 %t4, %t2
1435 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1_logical(i32 %x) {
1436 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1_logical(
1437 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1438 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 9
1439 ; CHECK-NEXT: ret i1 [[TMP2]]
1441 %t1 = and i32 %x, 12
1442 %t2 = icmp eq i32 %t1, 0
1444 %t4 = icmp ne i32 %t3, 1
1445 %t5 = select i1 %t4, i1 true, i1 %t2
1449 ; ((X & 14) == 0 | (X & 3) != 1) -> !((X & 14) != 0 & (X & 3) == 1) ->
1451 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b(i32 %x) {
1452 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b(
1453 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
1454 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1455 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1456 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
1457 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1458 ; CHECK-NEXT: ret i1 [[T5]]
1460 %t1 = and i32 %x, 14
1461 %t2 = icmp eq i32 %t1, 0
1463 %t4 = icmp ne i32 %t3, 1
1464 %t5 = or i1 %t4, %t2
1468 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b_logical(i32 %x) {
1469 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_1b_logical(
1470 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 14
1471 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1472 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1473 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 1
1474 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1475 ; CHECK-NEXT: ret i1 [[T5]]
1477 %t1 = and i32 %x, 14
1478 %t2 = icmp eq i32 %t1, 0
1480 %t4 = icmp ne i32 %t3, 1
1481 %t5 = select i1 %t4, i1 true, i1 %t2
1485 ; ((X & 3) == 0 | (X & 7) != 0) -> !((X & 3) != 0 & (X & 7) == 0) ->
1487 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2(i32 %x) {
1488 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2(
1489 ; CHECK-NEXT: ret i1 true
1492 %t2 = icmp eq i32 %t1, 0
1494 %t4 = icmp ne i32 %t3, 0
1495 %t5 = or i1 %t4, %t2
1499 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2_logical(i32 %x) {
1500 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_2_logical(
1501 ; CHECK-NEXT: ret i1 true
1504 %t2 = icmp eq i32 %t1, 0
1506 %t4 = icmp ne i32 %t3, 0
1507 %t5 = select i1 %t4, i1 true, i1 %t2
1511 ; ((X & 15) == 0 | (X & 7) != 0) -> !((X & 15) != 0 & (X & 7) == 0) ->
1512 ; !((X & 15) == 8) -> (X & 15) != 8
1513 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3(i32 %x) {
1514 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3(
1515 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1516 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 8
1517 ; CHECK-NEXT: ret i1 [[TMP2]]
1519 %t1 = and i32 %x, 15
1520 %t2 = icmp eq i32 %t1, 0
1522 %t4 = icmp ne i32 %t3, 0
1523 %t5 = or i1 %t4, %t2
1527 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3_logical(i32 %x) {
1528 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3_logical(
1529 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 15
1530 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 8
1531 ; CHECK-NEXT: ret i1 [[TMP2]]
1533 %t1 = and i32 %x, 15
1534 %t2 = icmp eq i32 %t1, 0
1536 %t4 = icmp ne i32 %t3, 0
1537 %t5 = select i1 %t4, i1 true, i1 %t2
1541 ; ((X & 15) == 0 | (X & 3) != 0) -> !((X & 15) != 0 & (X & 3) == 0) ->
1543 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b(i32 %x) {
1544 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b(
1545 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
1546 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1547 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1548 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
1549 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1550 ; CHECK-NEXT: ret i1 [[T5]]
1552 %t1 = and i32 %x, 15
1553 %t2 = icmp eq i32 %t1, 0
1555 %t4 = icmp ne i32 %t3, 0
1556 %t5 = or i1 %t4, %t2
1560 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b_logical(i32 %x) {
1561 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_3b_logical(
1562 ; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 15
1563 ; CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
1564 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X]], 3
1565 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
1566 ; CHECK-NEXT: [[T5:%.*]] = or i1 [[T4]], [[T2]]
1567 ; CHECK-NEXT: ret i1 [[T5]]
1569 %t1 = and i32 %x, 15
1570 %t2 = icmp eq i32 %t1, 0
1572 %t4 = icmp ne i32 %t3, 0
1573 %t5 = select i1 %t4, i1 true, i1 %t2
1577 ; ((X & 255) == 0 | (X & 15) != 8) -> !(((X & 255) != 0 & (X & 15) == 8)) ->
1578 ; !((X & 15) == 8) -> ((X & 15) != 8)
1579 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4(i32 %x) {
1580 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4(
1581 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1582 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1583 ; CHECK-NEXT: ret i1 [[T4]]
1585 %t1 = and i32 %x, 255
1586 %t2 = icmp eq i32 %t1, 0
1587 %t3 = and i32 %x, 15
1588 %t4 = icmp ne i32 %t3, 8
1589 %t5 = or i1 %t4, %t2
1593 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4_logical(i32 %x) {
1594 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_4_logical(
1595 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1596 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1597 ; CHECK-NEXT: ret i1 [[T4]]
1599 %t1 = and i32 %x, 255
1600 %t2 = icmp eq i32 %t1, 0
1601 %t3 = and i32 %x, 15
1602 %t4 = icmp ne i32 %t3, 8
1603 %t5 = select i1 %t4, i1 true, i1 %t2
1607 ; ((X & 15) == 0 | (X & 15) != 8) -> !(((X & 15) != 0 & (X & 15) == 8)) ->
1608 ; !((X & 15) == 8) -> ((X & 15) != 8)
1609 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5(i32 %x) {
1610 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5(
1611 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1612 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1613 ; CHECK-NEXT: ret i1 [[T4]]
1615 %t1 = and i32 %x, 15
1616 %t2 = icmp eq i32 %t1, 0
1617 %t3 = and i32 %x, 15
1618 %t4 = icmp ne i32 %t3, 8
1619 %t5 = or i1 %t4, %t2
1623 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5_logical(i32 %x) {
1624 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_5_logical(
1625 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1626 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1627 ; CHECK-NEXT: ret i1 [[T4]]
1629 %t1 = and i32 %x, 15
1630 %t2 = icmp eq i32 %t1, 0
1631 %t3 = and i32 %x, 15
1632 %t4 = icmp ne i32 %t3, 8
1633 %t5 = select i1 %t4, i1 true, i1 %t2
1637 ; ((X & 12) == 0 | (X & 15) != 8) -> !(((X & 12) != 0 & (X & 15) == 8)) ->
1638 ; !((X & 15) == 8) -> ((X & 15) != 8
1639 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6(i32 %x) {
1640 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6(
1641 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1642 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1643 ; CHECK-NEXT: ret i1 [[T4]]
1645 %t1 = and i32 %x, 12
1646 %t2 = icmp eq i32 %t1, 0
1647 %t3 = and i32 %x, 15
1648 %t4 = icmp ne i32 %t3, 8
1649 %t5 = or i1 %t4, %t2
1653 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6_logical(i32 %x) {
1654 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_6_logical(
1655 ; CHECK-NEXT: [[T3:%.*]] = and i32 [[X:%.*]], 15
1656 ; CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 8
1657 ; CHECK-NEXT: ret i1 [[T4]]
1659 %t1 = and i32 %x, 12
1660 %t2 = icmp eq i32 %t1, 0
1661 %t3 = and i32 %x, 15
1662 %t4 = icmp ne i32 %t3, 8
1663 %t5 = select i1 %t4, i1 true, i1 %t2
1667 ; ((X & 7) == 0 | (X & 15) != 8) -> !(((X & 7) != 0 & (X & 15) == 8)) ->
1669 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7(i32 %x) {
1670 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7(
1671 ; CHECK-NEXT: ret i1 true
1674 %t2 = icmp eq i32 %t1, 0
1675 %t3 = and i32 %x, 15
1676 %t4 = icmp ne i32 %t3, 8
1677 %t5 = or i1 %t4, %t2
1681 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7_logical(i32 %x) {
1682 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7_logical(
1683 ; CHECK-NEXT: ret i1 true
1686 %t2 = icmp eq i32 %t1, 0
1687 %t3 = and i32 %x, 15
1688 %t4 = icmp ne i32 %t3, 8
1689 %t5 = select i1 %t4, i1 true, i1 %t2
1693 ; ((X & 6) == 0 | (X & 15) != 8) -> !(((X & 6) != 0 & (X & 15) == 8)) ->
1695 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b(i32 %x) {
1696 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b(
1697 ; CHECK-NEXT: ret i1 true
1700 %t2 = icmp eq i32 %t1, 0
1701 %t3 = and i32 %x, 15
1702 %t4 = icmp ne i32 %t3, 8
1703 %t5 = or i1 %t4, %t2
1707 define i1 @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b_logical(i32 %x) {
1708 ; CHECK-LABEL: @masked_icmps_mask_notallzeros_bmask_mixed_negated_swapped_7b_logical(
1709 ; CHECK-NEXT: ret i1 true
1712 %t2 = icmp eq i32 %t1, 0
1713 %t3 = and i32 %x, 15
1714 %t4 = icmp ne i32 %t3, 8
1715 %t5 = select i1 %t4, i1 true, i1 %t2