[llvm] [SystemZ] SLP reductions: cost functions of reductions and scalarization (PR #112491)
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 04:22:09 PDT 2024
================
@@ -12982,7 +12982,15 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
TTI::SK_InsertSubvector, VecTy, std::nullopt, CostKind,
I * ScalarTyNumElements, cast<FixedVectorType>(ScalarTy));
} else {
- Cost = TTI->getScalarizationOverhead(VecTy, ~ShuffledElements,
+ // Add insertion costs for all elements, but not for loads that can be
+ // loaded directly into a vector element for free.
+ APInt FreeEltLoads = APInt::getZero(VL.size());
+ if (TTI->supportsEfficientVectorElementLoadStore())
+ for (unsigned I : seq<unsigned>(VL.size()))
+ if (VL[I]->hasOneUse() && isa<LoadInst>(VL[I]))
+ FreeEltLoads.setBit(I);
+ APInt DemandedElts = ~ShuffledElements & ~FreeEltLoads;
+ Cost = TTI->getScalarizationOverhead(VecTy, DemandedElts,
----------------
JonPsson1 wrote:
How could it affect other targets? Please clarify. AFIK, the FreeEltLoads is 0, so if a target does not support efficient vector element loads, it remains 0, so later on it becomes all-ones after inversion and is therefore a no-op in the bitwise AND (&) operation. So it seems in this case we pass in ~ShuffleElements just like before...
https://github.com/llvm/llvm-project/pull/112491
More information about the llvm-commits
mailing list