[llvm] 87bf2bf - [NFC][DAG] Simplify a giant expression in visitMul.
Amaury Séchet via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 11:58:27 PDT 2023
Author: Amaury Séchet
Date: 2023-05-18T18:58:07Z
New Revision: 87bf2bff0561c1cfb6e3864f194088242d06030f
URL: https://github.com/llvm/llvm-project/commit/87bf2bff0561c1cfb6e3864f194088242d06030f
DIFF: https://github.com/llvm/llvm-project/commit/87bf2bff0561c1cfb6e3864f194088242d06030f.diff
LOG: [NFC][DAG] Simplify a giant expression in visitMul.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 75b6d8630f365..7173f52b72846 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4288,13 +4288,14 @@ SDValue DAGCombiner::visitMUL(SDNode *N) {
// fold (mul x, -(1 << c)) -> -(x << c) or (-x) << c
if (N1IsConst && !N1IsOpaqueConst && ConstValue1.isNegatedPowerOf2()) {
unsigned Log2Val = (-ConstValue1).logBase2();
+ EVT ShiftVT = getShiftAmountTy(N0.getValueType());
+
// FIXME: If the input is something that is easily negated (e.g. a
// single-use add), we should put the negate there.
return DAG.getNode(ISD::SUB, DL, VT,
DAG.getConstant(0, DL, VT),
DAG.getNode(ISD::SHL, DL, VT, N0,
- DAG.getConstant(Log2Val, DL,
- getShiftAmountTy(N0.getValueType()))));
+ DAG.getConstant(Log2Val, DL, ShiftVT)));
}
// Attempt to reuse an existing umul_lohi/smul_lohi node, but only if the
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index c823792b611e1..97119e8be62d5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -15893,7 +15893,7 @@ bool RISCVTargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT,
Subtarget.hasStdExtM() || Subtarget.hasStdExtZmmul();
if (!VT.isScalarInteger())
return false;
-
+
// Omit the optimization if the sub target has the M extension and the data
// size exceeds XLen.
if (HasExtMOrZmmul && VT.getSizeInBits() > Subtarget.getXLen())
More information about the llvm-commits
mailing list