Revert "[InstCombine] Add one use limitation for (X * C2) << C1 --> X * (C2 << C1)"

This reverts commit b543d28df7.
This commit is contained in:
chenglin.bi 2022-04-22 00:56:20 +08:00
parent 0edb262d91
commit 25aba1abb5
2 changed files with 2 additions and 5 deletions

View File

@ -972,10 +972,7 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) {
return BinaryOperator::CreateShl(ConstantExpr::getShl(C2, C1), X);
// (X * C2) << C1 --> X * (C2 << C1)
// The one-use check is not strictly necessary, but codegen may not be
// able to invert the transform and perf may suffer with an extra mul
// instruction.
if (match(Op0, m_OneUse(m_Mul(m_Value(X), m_Constant(C2)))))
if (match(Op0, m_Mul(m_Value(X), m_Constant(C2))))
return BinaryOperator::CreateMul(X, ConstantExpr::getShl(C2, C1));
// shl (zext i1 X), C1 --> select (X, 1 << C1, 0)

View File

@ -28,7 +28,7 @@ declare void @use(i55 %0)
define i55 @test6a_negative_oneuse(i55 %A) {
; CHECK-LABEL: @test6a_negative_oneuse(
; CHECK-NEXT: [[B:%.*]] = mul i55 [[A:%.*]], 3
; CHECK-NEXT: [[C:%.*]] = shl i55 [[B]], 1
; CHECK-NEXT: [[C:%.*]] = mul i55 [[A]], 6
; CHECK-NEXT: call void @use(i55 [[B]])
; CHECK-NEXT: ret i55 [[C]]
;