================
@@ -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:
Frankly, because it would require to add yet another hook in TTI to account the
cost properly aka it's another situation, where SLP knows the context better (N
consecutive loads covering all lanes, with the best alignment among them, which
only SLP knows).
https://github.com/llvm/llvm-project/pull/228903
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits