[llvm] [SLP]Add GEP cost estimation for gathered loads. (PR #80867)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 10:54:49 PST 2024
================
@@ -7170,14 +7170,43 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
TTI.getMemoryOpCost(Instruction::Load, LoadTy, Alignment,
LI->getPointerAddressSpace(), CostKind,
TTI::OperandValueInfo(), LI);
+ // Estimate GEP cost.
+ SmallVector<Value *> PointerOps(VF);
+ for (auto [I, V] : enumerate(VL.slice(P, VF)))
+ PointerOps[I] = cast<LoadInst>(V)->getPointerOperand();
+ InstructionCost ScalarGEPCost;
+ InstructionCost VectorGEPCost;
+ std::tie(ScalarGEPCost, VectorGEPCost) =
+ getGEPCosts(TTI, PointerOps, LI->getPointerOperand(),
+ Instruction::Load, CostKind, LI->getType(), LoadTy);
+ GatherCost += VectorGEPCost - ScalarGEPCost;
}
for (unsigned P : ScatterVectorized) {
auto *LI0 = cast<LoadInst>(VL[P]);
- Align CommonAlignment =
- computeCommonAlignment<LoadInst>(VL.slice(P, VF));
+ ArrayRef<Value *> Slice = VL.slice(P, VF);
+ Align CommonAlignment = computeCommonAlignment<LoadInst>(Slice);
GatherCost += TTI.getGatherScatterOpCost(
Instruction::Load, LoadTy, LI0->getPointerOperand(),
/*VariableMask=*/false, CommonAlignment, CostKind, LI0);
+ // Estimate GEP cost.
+ SmallVector<Value *> PointerOps(VF);
+ for (auto [I, V] : enumerate(Slice))
+ PointerOps[I] = cast<LoadInst>(V)->getPointerOperand();
+ OrdersType Order;
+ if (sortPtrAccesses(PointerOps, LI0->getType(), *R.DL, *R.SE,
----------------
preames wrote:
This bit of code is costing as-if we sort the accesses, but I don't see the cost of that shuffle being account for anywhere. Am I missing something?
https://github.com/llvm/llvm-project/pull/80867
More information about the llvm-commits
mailing list