[PATCH] D153106: [CSKY] Optimize multiplication with immediates
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 02:24:17 PDT 2023
benshi001 added inline comments.
================
Comment at: llvm/lib/Target/CSKY/CSKYISelLowering.cpp:1394
+ if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2() ||
+ (1 - Imm).isPowerOf2())
+ return true;
----------------
benshi001 wrote:
> 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.
Especially, for example,
`a * -4097` will be generated to
```
lsli16, a1, a0, 12
addu16 a1, a0
movi16 a0, 0
subu16 a0, a1
```
An extra 'movi16` is needed.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153106/new/
https://reviews.llvm.org/D153106
More information about the llvm-commits
mailing list