@@ -36,13 +36,9 @@ define i32 @add_select_cmp_and2(i32 %in) {
36
36
37
37
define i32 @add_select_cmp_and3 (i32 %in ) {
38
38
; CHECK-LABEL: @add_select_cmp_and3(
39
- ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 3
39
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 7
40
40
; CHECK-NEXT: [[TEMP:%.*]] = mul nuw nsw i32 [[TMP1]], 72
41
- ; CHECK-NEXT: [[BITOP2:%.*]] = and i32 [[IN]], 4
42
- ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[BITOP2]], 0
43
- ; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[CMP2]], i32 0, i32 288
44
- ; CHECK-NEXT: [[OUT:%.*]] = or disjoint i32 [[TEMP]], [[SEL2]]
45
- ; CHECK-NEXT: ret i32 [[OUT]]
41
+ ; CHECK-NEXT: ret i32 [[TEMP]]
46
42
;
47
43
%bitop0 = and i32 %in , 1
48
44
%cmp0 = icmp eq i32 %bitop0 , 0
@@ -60,12 +56,9 @@ define i32 @add_select_cmp_and3(i32 %in) {
60
56
61
57
define i32 @add_select_cmp_and4 (i32 %in ) {
62
58
; CHECK-LABEL: @add_select_cmp_and4(
63
- ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 3
64
- ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
65
- ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[IN]], 12
59
+ ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[IN:%.*]], 15
66
60
; CHECK-NEXT: [[TEMP3:%.*]] = mul nuw nsw i32 [[TMP2]], 72
67
- ; CHECK-NEXT: [[OUT1:%.*]] = or disjoint i32 [[OUT]], [[TEMP3]]
68
- ; CHECK-NEXT: ret i32 [[OUT1]]
61
+ ; CHECK-NEXT: ret i32 [[TEMP3]]
69
62
;
70
63
%bitop0 = and i32 %in , 1
71
64
%cmp0 = icmp eq i32 %bitop0 , 0
@@ -323,6 +316,87 @@ define <2 x i32> @add_select_cmp_vec_nonunique(<2 x i32> %in) {
323
316
%out = or disjoint <2 x i32 > %sel0 , %sel1
324
317
ret <2 x i32 > %out
325
318
}
319
+
320
+ define i32 @add_select_cmp_mixed1 (i32 %in ) {
321
+ ; CHECK-LABEL: @add_select_cmp_mixed1(
322
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 3
323
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
324
+ ; CHECK-NEXT: ret i32 [[OUT]]
325
+ ;
326
+ %mask = and i32 %in , 1
327
+ %sel0 = mul i32 %mask , 72
328
+ %bitop1 = and i32 %in , 2
329
+ %cmp1 = icmp eq i32 %bitop1 , 0
330
+ %sel1 = select i1 %cmp1 , i32 0 , i32 144
331
+ %out = or disjoint i32 %sel0 , %sel1
332
+ ret i32 %out
333
+ }
334
+
335
+ define i32 @add_select_cmp_mixed2 (i32 %in ) {
336
+ ; CHECK-LABEL: @add_select_cmp_mixed2(
337
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 3
338
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
339
+ ; CHECK-NEXT: ret i32 [[OUT]]
340
+ ;
341
+ %bitop0 = and i32 %in , 1
342
+ %cmp0 = icmp eq i32 %bitop0 , 0
343
+ %mask = and i32 %in , 2
344
+ %sel0 = select i1 %cmp0 , i32 0 , i32 72
345
+ %sel1 = mul i32 %mask , 72
346
+ %out = or disjoint i32 %sel0 , %sel1
347
+ ret i32 %out
348
+ }
349
+
350
+ define i32 @add_select_cmp_and_mul (i32 %in ) {
351
+ ; CHECK-LABEL: @add_select_cmp_and_mul(
352
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[IN:%.*]], 3
353
+ ; CHECK-NEXT: [[OUT:%.*]] = mul nuw nsw i32 [[TMP1]], 72
354
+ ; CHECK-NEXT: ret i32 [[OUT]]
355
+ ;
356
+ %mask0 = and i32 %in , 1
357
+ %sel0 = mul i32 %mask0 , 72
358
+ %mask1 = and i32 %in , 2
359
+ %sel1 = mul i32 %mask1 , 72
360
+ %out = or disjoint i32 %sel0 , %sel1
361
+ ret i32 %out
362
+ }
363
+
364
+ define i32 @add_select_cmp_mixed2_mismatch (i32 %in ) {
365
+ ; CHECK-LABEL: @add_select_cmp_mixed2_mismatch(
366
+ ; CHECK-NEXT: [[BITOP0:%.*]] = and i32 [[IN:%.*]], 1
367
+ ; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[BITOP0]], 0
368
+ ; CHECK-NEXT: [[MASK:%.*]] = and i32 [[IN]], 2
369
+ ; CHECK-NEXT: [[SEL0:%.*]] = select i1 [[CMP0]], i32 0, i32 73
370
+ ; CHECK-NEXT: [[SEL1:%.*]] = mul nuw nsw i32 [[MASK]], 72
371
+ ; CHECK-NEXT: [[OUT:%.*]] = or disjoint i32 [[SEL0]], [[SEL1]]
372
+ ; CHECK-NEXT: ret i32 [[OUT]]
373
+ ;
374
+ %bitop0 = and i32 %in , 1
375
+ %cmp0 = icmp eq i32 %bitop0 , 0
376
+ %mask = and i32 %in , 2
377
+ %sel0 = select i1 %cmp0 , i32 0 , i32 73
378
+ %sel1 = mul i32 %mask , 72
379
+ %out = or disjoint i32 %sel0 , %sel1
380
+ ret i32 %out
381
+ }
382
+
383
+ define i32 @add_select_cmp_and_mul_mismatch (i32 %in ) {
384
+ ; CHECK-LABEL: @add_select_cmp_and_mul_mismatch(
385
+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[IN:%.*]] to i1
386
+ ; CHECK-NEXT: [[SEL0:%.*]] = select i1 [[TMP1]], i32 73, i32 0
387
+ ; CHECK-NEXT: [[MASK1:%.*]] = and i32 [[IN]], 2
388
+ ; CHECK-NEXT: [[SEL1:%.*]] = mul nuw nsw i32 [[MASK1]], 72
389
+ ; CHECK-NEXT: [[OUT:%.*]] = or disjoint i32 [[SEL0]], [[SEL1]]
390
+ ; CHECK-NEXT: ret i32 [[OUT]]
391
+ ;
392
+ %mask0 = and i32 %in , 1
393
+ %sel0 = mul i32 %mask0 , 73
394
+ %mask1 = and i32 %in , 2
395
+ %sel1 = mul i32 %mask1 , 72
396
+ %out = or disjoint i32 %sel0 , %sel1
397
+ ret i32 %out
398
+ }
399
+
326
400
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
327
401
; CONSTSPLAT: {{.*}}
328
402
; CONSTVEC: {{.*}}
0 commit comments