[llvm-branch-commits] [llvm] [SLP] Cancel the phantom load saving on fadd reductions that lose an fma (PR #228903)
Dmitry Sidorov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 7 12:50:31 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);
+ }
----------------
MrSidims wrote:
I'm not saying, that there is nothing to fix on AMDGPU TTI side - https://github.com/llvm/llvm-project/blob/3a829ed35f2231fe456fbda8df51920b1016c0ec/llvm/test/Analysis/CostModel/AMDGPU/load.ll is jsut wrong, yet SLP would still get something like this patch in the end.
https://github.com/llvm/llvm-project/pull/228903
More information about the llvm-branch-commits
mailing list