[llvm] [RISCV] Add 2^N + 2^M expanding pattern for mul (PR #137954)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 11:48:29 PDT 2025
================
@@ -15653,22 +15677,7 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(ISD::SUB, DL, VT, Shift1, Mul359);
}
}
- }
- // 2^N - 2^M -> (sub (shl X, C1), (shl X, C2))
- uint64_t MulAmtLowBit = MulAmt & (-MulAmt);
- if (isPowerOf2_64(MulAmt + MulAmtLowBit)) {
- uint64_t ShiftAmt1 = MulAmt + MulAmtLowBit;
- SDLoc DL(N);
- SDValue Shift1 = DAG.getNode(ISD::SHL, DL, VT, N->getOperand(0),
- DAG.getConstant(Log2_64(ShiftAmt1), DL, VT));
- SDValue Shift2 =
- DAG.getNode(ISD::SHL, DL, VT, N->getOperand(0),
- DAG.getConstant(Log2_64(MulAmtLowBit), DL, VT));
- return DAG.getNode(ISD::SUB, DL, VT, Shift1, Shift2);
- }
-
- if (HasShlAdd) {
----------------
preames wrote:
It combines with the if-clause above, which uses the same test.
https://github.com/llvm/llvm-project/pull/137954
More information about the llvm-commits
mailing list