[PATCH] D58950: [PowerPC] Strength reduction of multiply by a constant by shift and add/sub in place
Zixuan Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 19:23:08 PDT 2019
wuzish marked 2 inline comments as done.
wuzish added inline comments.
================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14591
+
+ // The cycles of related operation are showed as a table above.
+ // Only do (mul x, -(2^N + 1)) => -(add (shl x, N), x) for vector type.
----------------
jsji wrote:
> These are for P9 right? I believe P8 is different no?
Hmm, well. Actually I only have cycles information table about P9, so we can only do for P9 and leave P8 as TODO, and also change comments into `// TODO: enhance the condition for subtarget before pwr9`
================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14593
+ // Only do (mul x, -(2^N + 1)) => -(add (shl x, N), x) for vector type.
+ // Because vector type mul costs more cycles than scalar type,
+ // it's worthy to do such opt.
----------------
jsji wrote:
> ? I am confused: the combination here is doing strength reduction from `mul` to `shl`. Why we are comparing the cycles between vector type and scalar type? Should we compare the cycles for `mul` seq and `shl` seq for the SAME type?
Because this transformation replacement are 3 instrs. So it's not profitable for scalar mul operation because scalar mul takes 5 cycles, but it's profitable for vector mul operation because vector mul takes 7 cycles.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58950/new/
https://reviews.llvm.org/D58950
More information about the llvm-commits
mailing list