[llvm] [RISCV] Expand constant multiplication for targets without M extension (PR #137195)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 11:59:33 PDT 2025
================
@@ -15531,20 +15631,23 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
if (DAG.getMachineFunction().getFunction().hasMinSize())
return SDValue();
- if (DCI.isBeforeLegalize() || DCI.isCalledByLegalizer())
- return SDValue();
-
if (VT != Subtarget.getXLenVT())
return SDValue();
- const bool HasShlAdd =
- Subtarget.hasStdExtZba() || Subtarget.hasVendorXTHeadBa();
-
ConstantSDNode *CNode = dyn_cast<ConstantSDNode>(N->getOperand(1));
if (!CNode)
return SDValue();
uint64_t MulAmt = CNode->getZExtValue();
+ if (!Subtarget.hasStdExtM() && !Subtarget.hasStdExtZmmul())
----------------
preames wrote:
Code structure wise, you want this to fall into the generic expansion code for the no-M case, and then only resort to expensive expansion if none of the existing rules work.
Consider something like the following:
bool ShouldExpandMul = (!DCI.isBeforeLegalize() && !DCI.isCalledByLegalizer()) || !Subtarget.hasStdExtZmmul().
Then put the call to expandMulToBasicOps under the Subtarget.hasStdExtZmmul() guard at the bottom.
https://github.com/llvm/llvm-project/pull/137195
More information about the llvm-commits
mailing list