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

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 18:14:15 PDT 2022


hiraditya added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:13599
+    if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2() ||
+        (1 - Imm).isPowerOf2() || (-1 - Imm).isPowerOf2())
+      return true;
----------------
Allen wrote:
> hiraditya wrote:
> > What is the rationale behind checking `Imm+1` etc?
> I think it can use **shl + sub** to replace **mul**, such as
> https://gcc.godbolt.org/z/szh7Eb9K8
> 
> BTW: some other target, such as **RISCVTargetLowering::decomposeMulByConstant** also has such logic
as per godbolt link, it is already happening in some cases?


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

https://reviews.llvm.org/D132322



More information about the llvm-commits mailing list