[llvm] [AArch64][CostModel] Improve cost estimate of scalarizing a vector di… (PR #118055)
Sushant Gokhale via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 07:26:05 PST 2025
================
@@ -3572,6 +3573,40 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
Cost *= 4;
return Cost;
} else {
+ // If the information about individual scalars being vectorized is
+ // available, this yeilds better cost estimation.
+ if (auto *VTy = dyn_cast<FixedVectorType>(Ty); VTy && !Args.empty()) {
+ assert(Args.size() % 2 == 0 && "Args size should be even");
+ InstructionCost InsertExtractCost =
+ ST->getVectorInsertExtractBaseCost();
+ // If the cost of single sdiv is inquired through the cost-model.
+ // FIXME: remove the isa checks once the PR 122236 lands.
+ if (Args.size() == 2 &&
+ !(isa<ConstantVector>(Args[1]) ||
+ isa<ConstantDataVector>(Args[1]) ||
+ isa<ConstantExpr>(Args[1])) &&
----------------
sushgokh wrote:
the cost of the division when the divisor is constant is less than the case where the divisor is unknown.
When we are considering scalarizing cost, we are considering div cost of each lane and additional insert/extract cost. This is where this patch yeilds less cost with extra knowledge about the values that go into that lanes
https://github.com/llvm/llvm-project/pull/118055
More information about the llvm-commits
mailing list