Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 76aa95e

Browse files
committed
[InstCombine] add tests for shift-shift folds; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293205 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 04acf64 commit 76aa95e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/Transforms/InstCombine/apint-shift.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,66 @@ define i11 @test23(i44 %A) {
429429
ret i11 %D
430430
}
431431

432+
; Fold lshr (shl X, C), C -> and X, C' regardless of the number of uses of the shl.
433+
434+
define i44 @shl_lshr_eq_amt_multi_use(i44 %A) {
435+
; CHECK-LABEL: @shl_lshr_eq_amt_multi_use(
436+
; CHECK-NEXT: [[B:%.*]] = shl i44 %A, 33
437+
; CHECK-NEXT: [[C:%.*]] = and i44 %A, 2047
438+
; CHECK-NEXT: [[D:%.*]] = or i44 [[B]], [[C]]
439+
; CHECK-NEXT: ret i44 [[D]]
440+
;
441+
%B = shl i44 %A, 33
442+
%C = lshr i44 %B, 33
443+
%D = add i44 %B, %C
444+
ret i44 %D
445+
}
446+
447+
; FIXME: Fold vector lshr (shl X, C), C -> and X, C' regardless of the number of uses of the shl.
448+
449+
define <2 x i44> @shl_lshr_eq_amt_multi_use_splat_vec(<2 x i44> %A) {
450+
; CHECK-LABEL: @shl_lshr_eq_amt_multi_use_splat_vec(
451+
; CHECK-NEXT: [[B:%.*]] = shl <2 x i44> %A, <i44 33, i44 33>
452+
; CHECK-NEXT: [[C:%.*]] = lshr exact <2 x i44> [[B]], <i44 33, i44 33>
453+
; CHECK-NEXT: [[D:%.*]] = or <2 x i44> [[B]], [[C]]
454+
; CHECK-NEXT: ret <2 x i44> [[D]]
455+
;
456+
%B = shl <2 x i44> %A, <i44 33, i44 33>
457+
%C = lshr <2 x i44> %B, <i44 33, i44 33>
458+
%D = add <2 x i44> %B, %C
459+
ret <2 x i44> %D
460+
}
461+
462+
; FIXME: Fold shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
463+
464+
define i43 @lshr_shl_eq_amt_multi_use(i43 %A) {
465+
; CHECK-LABEL: @lshr_shl_eq_amt_multi_use(
466+
; CHECK-NEXT: [[B:%.*]] = lshr i43 %A, 23
467+
; CHECK-NEXT: [[C:%.*]] = shl nuw i43 [[B]], 23
468+
; CHECK-NEXT: [[D:%.*]] = mul i43 [[B]], [[C]]
469+
; CHECK-NEXT: ret i43 [[D]]
470+
;
471+
%B = lshr i43 %A, 23
472+
%C = shl i43 %B, 23
473+
%D = mul i43 %B, %C
474+
ret i43 %D
475+
}
476+
477+
; FIXME: Fold vector shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
478+
479+
define <2 x i43> @lshr_shl_eq_amt_multi_use_splat_vec(<2 x i43> %A) {
480+
; CHECK-LABEL: @lshr_shl_eq_amt_multi_use_splat_vec(
481+
; CHECK-NEXT: [[B:%.*]] = lshr <2 x i43> %A, <i43 23, i43 23>
482+
; CHECK-NEXT: [[C:%.*]] = shl nuw <2 x i43> [[B]], <i43 23, i43 23>
483+
; CHECK-NEXT: [[D:%.*]] = mul <2 x i43> [[B]], [[C]]
484+
; CHECK-NEXT: ret <2 x i43> [[D]]
485+
;
486+
%B = lshr <2 x i43> %A, <i43 23, i43 23>
487+
%C = shl <2 x i43> %B, <i43 23, i43 23>
488+
%D = mul <2 x i43> %B, %C
489+
ret <2 x i43> %D
490+
}
491+
432492
define i37 @test25(i37 %tmp.2, i37 %AA) {
433493
; CHECK-LABEL: @test25(
434494
; CHECK-NEXT: [[TMP_3:%.*]] = and i37 %tmp.2, -131072

0 commit comments

Comments
 (0)