forked from OSchip/llvm-project
[InstCombine] remove unnecessary one-use check from (C2 << X) << C1 fold
The restriction goes back to:
16f18ed7b5
...but the fold only replaces a shift with a shift, so that's not necessary.
Generalizing to other opcodes is planned as a follow-up.
This commit is contained in:
parent
a004438959
commit
c5d942a4fb
|
@ -1010,7 +1010,7 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) {
|
|||
Constant *C2;
|
||||
Value *X;
|
||||
// (C2 << X) << C1 --> (C2 << C1) << X
|
||||
if (match(Op0, m_OneUse(m_Shl(m_Constant(C2), m_Value(X)))))
|
||||
if (match(Op0, m_Shl(m_Constant(C2), m_Value(X))))
|
||||
return BinaryOperator::CreateShl(ConstantExpr::getShl(C2, C1), X);
|
||||
|
||||
// (X * C2) << C1 --> X * (C2 << C1)
|
||||
|
|
|
@ -325,7 +325,7 @@ define i32 @shl_shl_constants_use(i32 %x) {
|
|||
; CHECK-LABEL: @shl_shl_constants_use(
|
||||
; CHECK-NEXT: [[S:%.*]] = shl i32 -2013265920, [[X:%.*]]
|
||||
; CHECK-NEXT: call void @use32(i32 [[S]])
|
||||
; CHECK-NEXT: [[R:%.*]] = shl i32 [[S]], 3
|
||||
; CHECK-NEXT: [[R:%.*]] = shl i32 1073741824, [[X]]
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
%s = shl i32 2281701376, %x ; 0x8800_0000
|
||||
|
|
Loading…
Reference in New Issue