[PATCH] D132322: [AArch64][SelectionDAG] Optimize multiplication by constant

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 14:43:44 PDT 2022


dmgreen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:14562
+      // the operand of madd/msub should not be const value.
+      if (!AddSub->hasOneUse() || !isIntOrFPConstant(AddSub->getOperand(1)))
+        return SDValue();
----------------
I don't think it matters it the AddSub has one use? (It might for some other optimizations, but that can be a separate patch).

It matters that for a sub the `AddSub->operand(1) == N`.  If it is `AddSub->operand(0) == N`, then we cannot fold to a msub, so that shouldn't block the transform to add+shifts.
The isIntOrFPConstant check can check for isLegalAddImmediate, to be a little more precise where it will generate a mul+addri or subri.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132322/new/

https://reviews.llvm.org/D132322



More information about the llvm-commits mailing list