[llvm] [X86] Use shift+add/sub for vXi8 splat multiplies (PR #174110)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 28 08:03:15 PST 2026


================
@@ -3389,6 +3389,15 @@ bool X86TargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT,
   if (!ISD::isConstantSplatVector(C.getNode(), MulC))
     return false;
 
+  if (VT.isVector() && VT.getScalarSizeInBits() == 8) {
+    // Decompose 2^m ± 2^n as 2^(a+b) ± 2^b
+    APInt ShiftedMulC = MulC.abs();
+    unsigned TZeros = ShiftedMulC == 2 ? 0 : ShiftedMulC.countr_zero();
----------------
RKSimon wrote:

Your comment doesn't explain this behaviour

https://github.com/llvm/llvm-project/pull/174110


More information about the llvm-commits mailing list