================
@@ -19404,6 +19420,29 @@ 
BoUpSLP::calculateTreeCostAndTrimNonProfitable(ArrayRef<Value *> VectorizedVals,
       return false;
     return IsExternallyUsedV(V);
   };
+  // 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.
+  bool LosesFMAs = reductionLosesFMAs(RdxKind, RdxFMF, VectorizedVals);
+  auto GetCoalescedLoadSaving = [&](const TreeEntry &TE) -> InstructionCost {
+    if (!LosesFMAs || !TE.hasState() || TE.isGather() ||
+        TE.getOpcode() != Instruction::Load ||
+        TE.State != TreeEntry::Vectorize || TE.getInterleaveFactor())
+      return 0;
+    if (DeletedNodes.contains(&TE) || TransformedToGatherNodes.contains(&TE))
+      return 0;
+    if (!TE.ReuseShuffleIndices.empty() || !TE.ReorderIndices.empty() ||
+        MinBWs.contains(&TE))
+      return 0;
+    if (!all_of(TE.Scalars, IsaPred<LoadInst>))
+      return 0;
+    auto *LI0 = cast<LoadInst>(TE.getMainOp());
+    Align BestAlign = LI0->getAlign();
+    for (Value *V : TE.Scalars)
+      BestAlign = std::max(BestAlign, cast<LoadInst>(V)->getAlign());
+    return TTI->getLoadCoalescingSaving(
+        LI0->getType(), TE.Scalars.size(), BestAlign,
+        LI0->getPointerAddressSpace(), CostKind);
----------------
MrSidims wrote:

Moved to getEntryCost 

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

Reply via email to