[llvm-branch-commits] [llvm] [SLP] Cancel the phantom load saving on fadd reductions that lose an fma (PR #228903)
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 7 12:54:48 PDT 2026
================
@@ -17591,6 +17610,19 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
Instruction::Load, VecTy, LI0->getAlign(),
LI0->getPointerAddressSpace(), CostKind,
TTI::getOperandInfo(LI0->getPointerOperand()));
+ // The vector load of a bundle saves nothing over scalar loads the
+ // target coalesces as well. A reduction that loses its fmas pays
+ // that saving back.
+ if (E->ReuseShuffleIndices.empty() && E->ReorderIndices.empty() &&
+ It == MinBWs.end() &&
+ reductionLosesFMAs(RdxKind, RdxFMF, VectorizedVals)) {
+ Align BestAlign = LI0->getAlign();
+ for (Value *V : VL)
+ BestAlign = std::max(BestAlign, cast<LoadInst>(V)->getAlign());
+ VecLdCost += TTI->getLoadCoalescingSaving(
+ LI0->getType(), VL.size(), BestAlign,
+ LI0->getPointerAddressSpace(), CostKind);
+ }
----------------
alexey-bataev wrote:
> and if you don't mind I'd like to have an order of patches looking like: fix SLP -> fix TTI -> adjust SLP if necessary because not only SLP will be affected
What's wrong with SLP, that you want to fix in 1st step?
https://github.com/llvm/llvm-project/pull/228903
More information about the llvm-branch-commits
mailing list