[llvm] [AArch64][CostModel] Updated inserelement/extractelement costs (PR #220627)

Utpal Bora via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 04:23:51 PDT 2026


================
@@ -4611,6 +4599,28 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
     if (Index == 0 && !Ty->getScalarType()->isIntegerTy())
       return 0;
 
+    // SVE has no scalar move to an arbitrary lane above the low 128-bit portion
+    // of a Z register, e.g. there is no equivalent of "mov z0.d[9], d0".
+    // Fixed-length vectors wider than 128 bits therefore need
+    // [splice]/index/pred/splat/cmp/pred-mov when scalarizing inserts for those
+    // lanes, so model them as more expensive than ordinary NEON lane accesses.
+    if (ST->useSVEForFixedLengthVectors()) {
+      InstructionCost Cost = CostKind == TTI::TCK_CodeSize
+                                 ? 1
+                                 : ST->getVectorInsertExtractBaseCost();
+      if (Index * Ty->getScalarSizeInBits() < 128)
----------------
utpalbora wrote:

For normal AArch64 scalar/vector element types (i32, i64, half, float, double), the `getScalarSizeInBits` is same for both original `Ty` and legalized type. It changes for arbitrary integer types. I have made the change.

https://github.com/llvm/llvm-project/pull/220627


More information about the llvm-commits mailing list