[llvm] [AArch64] [CostModel] Improve costs for scalar inserts into fixed-length SVE constant vector (PR #223638)
Utpal Bora via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 01:51:43 PDT 2026
================
@@ -4866,9 +4866,57 @@ InstructionCost AArch64TTIImpl::getScalarizationOverhead(
TTI::VectorInstrContext VIC) const {
if (isa<ScalableVectorType>(Ty))
return InstructionCost::getInvalid();
- if (Ty->getElementType()->isFloatingPointTy())
- return BaseT::getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
- CostKind);
+ if (Ty->getElementType()->isFloatingPointTy()) {
+ InstructionCost Cost = BaseT::getScalarizationOverhead(
+ Ty, DemandedElts, Insert, Extract, CostKind);
+
+ if (!Insert || VL.empty())
+ return Cost;
+
+ auto LT = getTypeLegalizationCost(Ty);
+ if (!ST->isNeonAvailable() || !LT.second.isFixedLengthVector() ||
+ LT.second.getFixedSizeInBits() <= 128)
+ return Cost;
+
+ auto HasNonUniformConstants = [&VL]() -> bool {
----------------
utpalbora wrote:
Thank you for the review. I agree that splitting this PR will be cleaner.
I am going to split the cost-model work as below:
- Fix the more accurate cost for `BUILD_VECTOR`s for wider vectors using SVE by costing inserts into each 128b segment
- Handle the specific case of splat(constant) + inserts
- Generalize per-lane scalarization costs for wide fixed-length vectors for other types
https://github.com/llvm/llvm-project/pull/223638
More information about the llvm-commits
mailing list