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

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 08:54:31 PDT 2026


================
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mattr=+sve | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64--linux-gnu"
+
+define void @fixed_sve_high_lane_insert_extract(<8 x i32> %vi32, <8 x float> %vf32, <4 x double> %vf64, i32 %i32, float %f, double %d) vscale_range(2, 0) {
+; CHECK-LABEL: 'fixed_sve_high_lane_insert_extract'
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ei32_elt0 = extractelement <8 x i32> %vi32, i32 0
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ei32_low = extractelement <8 x i32> %vi32, i32 3
+; CHECK-NEXT:  Cost Model: Found costs of RThru:3 CodeSize:2 Lat:3 SizeLat:3 for: %ei32_high = extractelement <8 x i32> %vi32, i32 4
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ii32_elt0 = insertelement <8 x i32> %vi32, i32 %i32, i32 0
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ii32_low = insertelement <8 x i32> %vi32, i32 %i32, i32 3
+; CHECK-NEXT:  Cost Model: Found costs of RThru:5 CodeSize:4 Lat:5 SizeLat:5 for: %ii32_high = insertelement <8 x i32> %vi32, i32 %i32, i32 4
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ef32_low = extractelement <8 x float> %vf32, i32 3
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ef32_high = extractelement <8 x float> %vf32, i32 4
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ef64_low = extractelement <4 x double> %vf64, i32 1
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %ef64_high = extractelement <4 x double> %vf64, i32 2
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %if32_low = insertelement <8 x float> %vf32, float %f, i32 3
+; CHECK-NEXT:  Cost Model: Found costs of RThru:5 CodeSize:4 Lat:5 SizeLat:5 for: %if32_high = insertelement <8 x float> %vf32, float %f, i32 4
+; CHECK-NEXT:  Cost Model: Found costs of RThru:2 CodeSize:1 Lat:2 SizeLat:2 for: %if64_low = insertelement <4 x double> %vf64, double %d, i32 1
+; CHECK-NEXT:  Cost Model: Found costs of RThru:5 CodeSize:4 Lat:5 SizeLat:5 for: %if64_high = insertelement <4 x double> %vf64, double %d, i32 2
+; CHECK-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+  %ei32_elt0 = extractelement <8 x i32> %vi32, i32 0
+  %ei32_low = extractelement <8 x i32> %vi32, i32 3
+  %ei32_high = extractelement <8 x i32> %vi32, i32 4
+  %ii32_elt0 = insertelement <8 x i32> %vi32, i32 %i32, i32 0
+  %ii32_low = insertelement <8 x i32> %vi32, i32 %i32, i32 3
+  %ii32_high = insertelement <8 x i32> %vi32, i32 %i32, i32 4
+  %ef32_low = extractelement <8 x float> %vf32, i32 3
----------------
sdesmalen-arm wrote:

this is missing a test for exact at element 0.

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


More information about the llvm-commits mailing list