@@ -406,7 +406,7 @@ define i32 @ashr_lowmask_use(i32 %x) {
406
406
; CHECK-LABEL: @ashr_lowmask_use(
407
407
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 1
408
408
; CHECK-NEXT: call void @use32(i32 [[A]])
409
- ; CHECK-NEXT: [[R:%.*]] = and i32 [[A ]], 2147483647
409
+ ; CHECK-NEXT: [[R:%.*]] = lshr i32 [[X ]], 1
410
410
; CHECK-NEXT: ret i32 [[R]]
411
411
;
412
412
%a = ashr i32 %x , 1
@@ -419,7 +419,7 @@ define <2 x i8> @ashr_lowmask_use_splat(<2 x i8> %x, <2 x i8>* %p) {
419
419
; CHECK-LABEL: @ashr_lowmask_use_splat(
420
420
; CHECK-NEXT: [[A:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 7, i8 7>
421
421
; CHECK-NEXT: store <2 x i8> [[A]], <2 x i8>* [[P:%.*]], align 2
422
- ; CHECK-NEXT: [[R:%.*]] = and <2 x i8> [[A ]], <i8 1 , i8 1 >
422
+ ; CHECK-NEXT: [[R:%.*]] = lshr <2 x i8> [[X ]], <i8 7 , i8 7 >
423
423
; CHECK-NEXT: ret <2 x i8> [[R]]
424
424
;
425
425
%a = ashr <2 x i8 > %x , <i8 7 , i8 7 >
@@ -428,6 +428,8 @@ define <2 x i8> @ashr_lowmask_use_splat(<2 x i8> %x, <2 x i8>* %p) {
428
428
ret <2 x i8 > %r
429
429
}
430
430
431
+ ; negative test - must keep all low bits
432
+
431
433
define i32 @ashr_not_lowmask1_use (i32 %x ) {
432
434
; CHECK-LABEL: @ashr_not_lowmask1_use(
433
435
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 24
@@ -441,6 +443,8 @@ define i32 @ashr_not_lowmask1_use(i32 %x) {
441
443
ret i32 %r
442
444
}
443
445
446
+ ; negative test - must keep all low bits
447
+
444
448
define i32 @ashr_not_lowmask2_use (i32 %x ) {
445
449
; CHECK-LABEL: @ashr_not_lowmask2_use(
446
450
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 24
@@ -454,6 +458,8 @@ define i32 @ashr_not_lowmask2_use(i32 %x) {
454
458
ret i32 %r
455
459
}
456
460
461
+ ; negative test - must keep only low bits
462
+
457
463
define i32 @ashr_not_lowmask3_use (i32 %x ) {
458
464
; CHECK-LABEL: @ashr_not_lowmask3_use(
459
465
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 24
@@ -1231,14 +1237,14 @@ define i32 @lowmask_sext_in_reg(i32 %x) {
1231
1237
ret i32 %and
1232
1238
}
1233
1239
1234
- ; Negative test - mismatched shift amounts
1240
+ ; Mismatched shift amounts, but the mask op can be replaced by a shift.
1235
1241
1236
1242
define i32 @lowmask_not_sext_in_reg (i32 %x ) {
1237
1243
; CHECK-LABEL: @lowmask_not_sext_in_reg(
1238
1244
; CHECK-NEXT: [[L:%.*]] = shl i32 [[X:%.*]], 19
1239
1245
; CHECK-NEXT: [[R:%.*]] = ashr i32 [[L]], 20
1240
1246
; CHECK-NEXT: call void @use32(i32 [[R]])
1241
- ; CHECK-NEXT: [[AND:%.*]] = and i32 [[R ]], 4095
1247
+ ; CHECK-NEXT: [[AND:%.*]] = lshr i32 [[L ]], 20
1242
1248
; CHECK-NEXT: ret i32 [[AND]]
1243
1249
;
1244
1250
%l = shl i32 %x , 19
0 commit comments