[llvm] 25aba1a - Revert "[InstCombine] Add one use limitation for (X * C2) << C1 --> X * (C2 << C1)"
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 09:56:37 PDT 2022
Author: chenglin.bi
Date: 2022-04-22T00:56:20+08:00
New Revision: 25aba1abb546a4486d2fe9c2bdb6d8c25047bf85
URL: https://github.com/llvm/llvm-project/commit/25aba1abb546a4486d2fe9c2bdb6d8c25047bf85
DIFF: https://github.com/llvm/llvm-project/commit/25aba1abb546a4486d2fe9c2bdb6d8c25047bf85.diff
LOG: Revert "[InstCombine] Add one use limitation for (X * C2) << C1 --> X * (C2 << C1)"
This reverts commit b543d28df7b067dcda833c717a59faa28c1151a1.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/apint-shift.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index c58c494ab550d..89558ee06745c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -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)
diff --git a/llvm/test/Transforms/InstCombine/apint-shift.ll b/llvm/test/Transforms/InstCombine/apint-shift.ll
index 78f78fcee95d6..039f263101f53 100644
--- a/llvm/test/Transforms/InstCombine/apint-shift.ll
+++ b/llvm/test/Transforms/InstCombine/apint-shift.ll
@@ -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]]
;
More information about the llvm-commits
mailing list