[llvm] [AArch64][TTI] Tune costs for mulh. (PR #225788)

Ricardo Jesus via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 07:12:19 PDT 2026


================
@@ -1,15 +1,32 @@
 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
 ; RUN: opt < %s -mtriple=aarch64 -passes="print<cost-model>" -cost-kind=all -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,NEON
-; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" -cost-kind=all -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,SVE
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" -cost-kind=all -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,SVE,SVE-STD
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve,+has-limited-64bit-vector-mul-bandwidth -passes="print<cost-model>" -cost-kind=all -disable-output 2>&1 | FileCheck %s --check-prefixes=CHECK,SVE,SVE-HIGH
 
 define void @smulh() {
-; CHECK-LABEL: 'smulh'
-; CHECK-NEXT:  Cost Model: Found costs of 4 for: %I8 = call i8 @llvm.smulh.i8(i8 poison, i8 poison)
-; CHECK-NEXT:  Cost Model: Found costs of 4 for: %I16 = call i16 @llvm.smulh.i16(i16 poison, i16 poison)
-; CHECK-NEXT:  Cost Model: Found costs of 4 for: %I32 = call i32 @llvm.smulh.i32(i32 poison, i32 poison)
-; CHECK-NEXT:  Cost Model: Found costs of 1 for: %I64 = call i64 @llvm.smulh.i64(i64 poison, i64 poison)
-; CHECK-NEXT:  Cost Model: Found costs of 4 for: %I128 = call i128 @llvm.smulh.i128(i128 poison, i128 poison)
-; CHECK-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+; NEON-LABEL: 'smulh'
+; NEON-NEXT:  Cost Model: Found costs of 4 for: %I8 = call i8 @llvm.smulh.i8(i8 poison, i8 poison)
+; NEON-NEXT:  Cost Model: Found costs of 4 for: %I16 = call i16 @llvm.smulh.i16(i16 poison, i16 poison)
+; NEON-NEXT:  Cost Model: Found costs of 2 for: %I32 = call i32 @llvm.smulh.i32(i32 poison, i32 poison)
+; NEON-NEXT:  Cost Model: Found costs of 1 for: %I64 = call i64 @llvm.smulh.i64(i64 poison, i64 poison)
+; NEON-NEXT:  Cost Model: Found costs of 8 for: %I128 = call i128 @llvm.smulh.i128(i128 poison, i128 poison)
+; NEON-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE-STD-LABEL: 'smulh'
+; SVE-STD-NEXT:  Cost Model: Found costs of 4 for: %I8 = call i8 @llvm.smulh.i8(i8 poison, i8 poison)
+; SVE-STD-NEXT:  Cost Model: Found costs of 4 for: %I16 = call i16 @llvm.smulh.i16(i16 poison, i16 poison)
+; SVE-STD-NEXT:  Cost Model: Found costs of 2 for: %I32 = call i32 @llvm.smulh.i32(i32 poison, i32 poison)
+; SVE-STD-NEXT:  Cost Model: Found costs of 1 for: %I64 = call i64 @llvm.smulh.i64(i64 poison, i64 poison)
+; SVE-STD-NEXT:  Cost Model: Found costs of 8 for: %I128 = call i128 @llvm.smulh.i128(i128 poison, i128 poison)
+; SVE-STD-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE-HIGH-LABEL: 'smulh'
+; SVE-HIGH-NEXT:  Cost Model: Found costs of 4 for: %I8 = call i8 @llvm.smulh.i8(i8 poison, i8 poison)
+; SVE-HIGH-NEXT:  Cost Model: Found costs of 4 for: %I16 = call i16 @llvm.smulh.i16(i16 poison, i16 poison)
+; SVE-HIGH-NEXT:  Cost Model: Found costs of 2 for: %I32 = call i32 @llvm.smulh.i32(i32 poison, i32 poison)
+; SVE-HIGH-NEXT:  Cost Model: Found costs of 1 for: %I64 = call i64 @llvm.smulh.i64(i64 poison, i64 poison)
+; SVE-HIGH-NEXT:  Cost Model: Found costs of RThru:32 CodeSize:8 Lat:8 SizeLat:8 for: %I128 = call i128 @llvm.smulh.i128(i128 poison, i128 poison)
----------------
rj-jesus wrote:

I don't know whether i128 should have such a high cost with +has-limited-64bit-vector-mul-bandwidth, but plain MULs have a similarly high cost (https://godbolt.org/z/WYqnT4a61).

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


More information about the llvm-commits mailing list