[PATCH] D25966: [AArch64] Lower multiplication by a constant int to shl+add+shl

Haicheng Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 08:03:18 PST 2016


haicheng added inline comments.


================
Comment at: lib/Target/AArch64/AArch64ISelLowering.cpp:7652
+    APInt ShiftedMinus1 = ShiftedInt - 1;
+    APInt ValuePlus1 = Value + 1;
+    SwapValues = false;
----------------
Gerolf wrote:
> Shouldn't ValuePlus1 be ConstantAPlus1? But then it should be ConstantAPlus1 = ShiftedInt (ConstantA) -1.  At this point I can't match your specification and your code. However, if I"m right about this I will need to dig deep into your test cases, too ...
ValueofC is used here to support (mul x, 2^N - 1) => (sub (shl x, N), x).  This patch does not support (mul x, (2^N - 1) * 2^M) => (shl (sub (shl x, N), x), M) yet.  If we want to support it in the future, we just need to use ConstantA here as you said.


================
Comment at: lib/Target/AArch64/AArch64ISelLowering.cpp:7667
+  } else {
+    APInt NegativeValuePlus1 = -Value + 1;
+    APInt NegativeValueMinus1 = -Value - 1;
----------------
Gerolf wrote:
> I think Value should be ShiftedMinus1 from here on.
Similarly, I do not support 
(mul x, -(2^N - 1) * 2^M) => (shl (sub x, (shl x, N)), M)
(mul x, -(2^N + 1) * 2^M) => -(shl (add (shl x, N), x), M)
So I use ValueOfC here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25966





More information about the llvm-commits mailing list