[PATCH] D153106: [CSKY] Optimize multiplication with immediates

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 01:47:41 PDT 2023


benshi001 marked 2 inline comments as done.
benshi001 added a comment.

Thanks. I will create a new test file for all the cases.



================
Comment at: llvm/lib/Target/CSKY/CSKYISelLowering.cpp:119
 
-  ISD::NodeType FPOpToExpand[] = {ISD::FSIN, ISD::FCOS, ISD::FSINCOS,
-                                  ISD::FPOW, ISD::FREM, ISD::FCOPYSIGN,
-                                  ISD::FP16_TO_FP, ISD::FP_TO_FP16};
+  ISD::NodeType FPOpToExpand[] = {
+      ISD::FSIN, ISD::FCOS,      ISD::FSINCOS,    ISD::FPOW,
----------------
zixuan-wu wrote:
> No related code change.
This is modified by `clang-format`.


================
Comment at: llvm/lib/Target/CSKY/CSKYISelLowering.cpp:1394
+    if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2() ||
+        (1 - Imm).isPowerOf2())
+      return true;
----------------
zixuan-wu wrote:
> Does `(-1 - Imm).isPowerOf2()` also make sense?
`(-1 - Imm).isPowerOf2()` will generate more instructions, I am not sure this is a win, though the multiplication is eliminated. So I left `(-1 - Imm)` unchanged. Maybe we can decide this case later.


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

https://reviews.llvm.org/D153106



More information about the llvm-commits mailing list