[llvm] [RISCV] Move strength reduction of mul X, 3/5/9*2^N to combine (PR #89966)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 14:42:00 PDT 2024
================
@@ -13426,10 +13426,27 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
if (MulAmt % Divisor != 0)
continue;
uint64_t MulAmt2 = MulAmt / Divisor;
- // 3/5/9 * 2^N -> shXadd (sll X, C), (sll X, C)
- // Matched in tablegen, avoid perturbing patterns.
- if (isPowerOf2_64(MulAmt2))
- return SDValue();
+ // 3/5/9 * 2^N -> shl (shXadd X, X), N
+ if (isPowerOf2_64(MulAmt2)) {
+ SDLoc DL(N);
+ SDValue X = N->getOperand(0);
+ // Put the shift first if we can fold a zext into the
+ // shift forming a sll.uw.
----------------
dtcxzyw wrote:
```suggestion
// shift forming a slli.uw.
```
https://github.com/llvm/llvm-project/pull/89966
More information about the llvm-commits
mailing list