@@ -294,6 +294,39 @@ define i8 @lshr_and_or(i8 %a, i8 %y) {
294
294
ret i8 %l
295
295
}
296
296
297
+ define i8 @lshr_and_or_disjoint (i8 %a , i8 %y ) {
298
+ ; CHECK-LABEL: @lshr_and_or_disjoint(
299
+ ; CHECK-NEXT: [[X:%.*]] = srem i8 [[A:%.*]], 42
300
+ ; CHECK-NEXT: [[B1:%.*]] = shl i8 [[X]], 2
301
+ ; CHECK-NEXT: [[Y_MASK:%.*]] = and i8 [[Y:%.*]], 52
302
+ ; CHECK-NEXT: [[L:%.*]] = or disjoint i8 [[Y_MASK]], [[B1]]
303
+ ; CHECK-NEXT: ret i8 [[L]]
304
+ ;
305
+ %x = srem i8 %a , 42 ; thwart complexity-based canonicalization
306
+ %r = lshr i8 %y , 2
307
+ %m = and i8 %r , 13
308
+ %b = or disjoint i8 %x , %m
309
+ %l = shl i8 %b , 2
310
+ ret i8 %l
311
+ }
312
+
313
+ define i8 @ashr_and_or_disjoint (i8 %a , i8 %y ) {
314
+ ; CHECK-LABEL: @ashr_and_or_disjoint(
315
+ ; CHECK-NEXT: [[X:%.*]] = srem i8 [[A:%.*]], 42
316
+ ; CHECK-NEXT: [[B1:%.*]] = shl i8 [[X]], 2
317
+ ; CHECK-NEXT: [[Y_MASK:%.*]] = and i8 [[Y:%.*]], 52
318
+ ; CHECK-NEXT: [[L:%.*]] = or disjoint i8 [[Y_MASK]], [[B1]]
319
+ ; CHECK-NEXT: ret i8 [[L]]
320
+ ;
321
+ %x = srem i8 %a , 42 ; thwart complexity-based canonicalization
322
+ %r = ashr i8 %y , 2
323
+ %m = and i8 %r , 13
324
+ %b = or disjoint i8 %x , %m
325
+ %l = shl i8 %b , 2
326
+ ret i8 %l
327
+ }
328
+
329
+
297
330
define <2 x i8 > @lshr_and_or_commute_splat (<2 x i8 > %a , <2 x i8 > %y ) {
298
331
; CHECK-LABEL: @lshr_and_or_commute_splat(
299
332
; CHECK-NEXT: [[X:%.*]] = srem <2 x i8> [[A:%.*]], <i8 42, i8 42>
@@ -614,8 +647,8 @@ define <8 x i16> @test_FoldShiftByConstant_CreateSHL2(<8 x i16> %in) {
614
647
615
648
define <16 x i8 > @test_FoldShiftByConstant_CreateAnd (<16 x i8 > %in0 ) {
616
649
; CHECK-LABEL: @test_FoldShiftByConstant_CreateAnd(
617
- ; CHECK-NEXT: [[TMP1 :%.*]] = mul <16 x i8> [[IN0:%.*]], <i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33>
618
- ; CHECK-NEXT: [[VSHL_N:%.*]] = and <16 x i8> [[TMP1 ]], <i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32>
650
+ ; CHECK-NEXT: [[VSRA_N2 :%.*]] = mul <16 x i8> [[IN0:%.*]], <i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33, i8 33>
651
+ ; CHECK-NEXT: [[VSHL_N:%.*]] = and <16 x i8> [[VSRA_N2 ]], <i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32, i8 -32>
619
652
; CHECK-NEXT: ret <16 x i8> [[VSHL_N]]
620
653
;
621
654
%vsra_n = ashr <16 x i8 > %in0 , <i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 , i8 5 >
0 commit comments