mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
[InstCombine] fold (X >>u C) << C --> X & (-1 << C)
We already have this fold when the lshr has one use, but it doesn't need that restriction. We may be able to remove some code from foldShiftedShift(). Also, move the similar: (X << C) >>u C --> X & (-1 >>u C) ...directly into visitLShr to help clean up foldShiftByConstOfShiftByConst(). That whole function seems questionable since it is called by commonShiftTransforms(), but there's really not much in common if we're checking the shift opcodes for every fold. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -459,12 +459,12 @@ define <2 x i44> @shl_lshr_eq_amt_multi_use_splat_vec(<2 x i44> %A) {
|
||||
ret <2 x i44> %D
|
||||
}
|
||||
|
||||
; FIXME: Fold shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
|
||||
; Fold shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
|
||||
|
||||
define i43 @lshr_shl_eq_amt_multi_use(i43 %A) {
|
||||
; CHECK-LABEL: @lshr_shl_eq_amt_multi_use(
|
||||
; CHECK-NEXT: [[B:%.*]] = lshr i43 %A, 23
|
||||
; CHECK-NEXT: [[C:%.*]] = shl nuw i43 [[B]], 23
|
||||
; CHECK-NEXT: [[C:%.*]] = and i43 %A, -8388608
|
||||
; CHECK-NEXT: [[D:%.*]] = mul i43 [[B]], [[C]]
|
||||
; CHECK-NEXT: ret i43 [[D]]
|
||||
;
|
||||
@@ -474,12 +474,12 @@ define i43 @lshr_shl_eq_amt_multi_use(i43 %A) {
|
||||
ret i43 %D
|
||||
}
|
||||
|
||||
; FIXME: Fold vector shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
|
||||
; Fold vector shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
|
||||
|
||||
define <2 x i43> @lshr_shl_eq_amt_multi_use_splat_vec(<2 x i43> %A) {
|
||||
; CHECK-LABEL: @lshr_shl_eq_amt_multi_use_splat_vec(
|
||||
; CHECK-NEXT: [[B:%.*]] = lshr <2 x i43> %A, <i43 23, i43 23>
|
||||
; CHECK-NEXT: [[C:%.*]] = shl nuw <2 x i43> [[B]], <i43 23, i43 23>
|
||||
; CHECK-NEXT: [[C:%.*]] = and <2 x i43> %A, <i43 -8388608, i43 -8388608>
|
||||
; CHECK-NEXT: [[D:%.*]] = mul <2 x i43> [[B]], [[C]]
|
||||
; CHECK-NEXT: ret <2 x i43> [[D]]
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user