[llvm] [CostModel][X86] clmul.ll - add test coverage for vpclmulqdq targets (PR #222610)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 04:08:48 PDT 2026


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/222610

None

>From bf93f4c9d6df683000c3446697385d0f54a2b055 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Thu, 10 Sep 2026 12:07:41 +0100
Subject: [PATCH] [CostModel][X86] clmul.ll - add test coverage for vpclmulqdq
 targets

---
 llvm/test/Analysis/CostModel/X86/clmul.ll | 71 +++++++++++++++--------
 1 file changed, 48 insertions(+), 23 deletions(-)

diff --git a/llvm/test/Analysis/CostModel/X86/clmul.ll b/llvm/test/Analysis/CostModel/X86/clmul.ll
index 19f9240ff0cb4..98c15276bf67c 100644
--- a/llvm/test/Analysis/CostModel/X86/clmul.ll
+++ b/llvm/test/Analysis/CostModel/X86/clmul.ll
@@ -1,6 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
-; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=all -mtriple=x86_64-unknown-linux-gnu -mattr=+pclmul | FileCheck %s --check-prefix=PCLMUL
-; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=all -mtriple=x86_64-unknown-linux-gnu -mattr=-pclmul | FileCheck %s --check-prefix=NO-PCLMUL
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=all -mtriple=x86_64-unknown-linux-gnu -mattr=+pclmul | FileCheck %s --check-prefixes=PCLMUL,PCLMUL128
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=all -mtriple=x86_64-unknown-linux-gnu -mattr=+vpclmulqdq | FileCheck %s --check-prefixes=PCLMUL,VPCLMULQDQ
+; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=all -mtriple=x86_64-unknown-linux-gnu -mattr=-pclmul | FileCheck %s --check-prefixes=NO-PCLMUL
 
 
 define void @clmul(i128 %a128, i128 %b128, i64 %a64, i64 %b64, i32 %a32, i32 %b32, i16 %a16, i16 %b16, i8 %a8, i8 %b8) {
@@ -29,13 +30,21 @@ define void @clmul(i128 %a128, i128 %b128, i64 %a64, i64 %b64, i32 %a32, i32 %b3
 }
 
 define void @clmul_128(<1 x i128> %a128, <1 x i128> %b128, <2 x i64> %a64, <2 x i64> %b64, <4 x i32> %a32, <4 x i32> %b32, <8 x i16> %a16, <8 x i16> %b16, <16 x i8> %a8, <16 x i8> %b8) {
-; PCLMUL-LABEL: 'clmul_128'
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:6 CodeSize:8 Lat:24 SizeLat:16 for: %call_i128 = call <1 x i128> @llvm.clmul.v1i128(<1 x i128> %a128, <1 x i128> %b128)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:3 CodeSize:4 Lat:12 SizeLat:8 for: %call_i64 = call <2 x i64> @llvm.clmul.v2i64(<2 x i64> %a64, <2 x i64> %b64)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:8 CodeSize:12 Lat:18 SizeLat:16 for: %call_i32 = call <4 x i32> @llvm.clmul.v4i32(<4 x i32> %a32, <4 x i32> %b32)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:48 CodeSize:48 Lat:80 SizeLat:48 for: %call_i16 = call <8 x i16> @llvm.clmul.v8i16(<8 x i16> %a16, <8 x i16> %b16)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:40 CodeSize:48 Lat:40 SizeLat:48 for: %call_i8 = call <16 x i8> @llvm.clmul.v16i8(<16 x i8> %a8, <16 x i8> %b8)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+; PCLMUL128-LABEL: 'clmul_128'
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:6 CodeSize:8 Lat:24 SizeLat:16 for: %call_i128 = call <1 x i128> @llvm.clmul.v1i128(<1 x i128> %a128, <1 x i128> %b128)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:3 CodeSize:4 Lat:12 SizeLat:8 for: %call_i64 = call <2 x i64> @llvm.clmul.v2i64(<2 x i64> %a64, <2 x i64> %b64)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:8 CodeSize:12 Lat:18 SizeLat:16 for: %call_i32 = call <4 x i32> @llvm.clmul.v4i32(<4 x i32> %a32, <4 x i32> %b32)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:48 CodeSize:48 Lat:80 SizeLat:48 for: %call_i16 = call <8 x i16> @llvm.clmul.v8i16(<8 x i16> %a16, <8 x i16> %b16)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:40 CodeSize:48 Lat:40 SizeLat:48 for: %call_i8 = call <16 x i8> @llvm.clmul.v16i8(<16 x i8> %a8, <16 x i8> %b8)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; VPCLMULQDQ-LABEL: 'clmul_128'
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:6 CodeSize:8 Lat:24 SizeLat:16 for: %call_i128 = call <1 x i128> @llvm.clmul.v1i128(<1 x i128> %a128, <1 x i128> %b128)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:3 CodeSize:4 Lat:12 SizeLat:8 for: %call_i64 = call <2 x i64> @llvm.clmul.v2i64(<2 x i64> %a64, <2 x i64> %b64)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:8 CodeSize:12 Lat:18 SizeLat:16 for: %call_i32 = call <4 x i32> @llvm.clmul.v4i32(<4 x i32> %a32, <4 x i32> %b32)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:48 CodeSize:48 Lat:80 SizeLat:48 for: %call_i16 = call <8 x i16> @llvm.clmul.v8i16(<8 x i16> %a16, <8 x i16> %b16)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:40 CodeSize:32 Lat:40 SizeLat:40 for: %call_i8 = call <16 x i8> @llvm.clmul.v16i8(<16 x i8> %a8, <16 x i8> %b8)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
 ;
 ; NO-PCLMUL-LABEL: 'clmul_128'
 ; NO-PCLMUL-NEXT:  Cost Model: Found costs of RThru:768 CodeSize:768 Lat:640 SizeLat:640 for: %call_i128 = call <1 x i128> @llvm.clmul.v1i128(<1 x i128> %a128, <1 x i128> %b128)
@@ -54,13 +63,21 @@ define void @clmul_128(<1 x i128> %a128, <1 x i128> %b128, <2 x i64> %a64, <2 x
 }
 
 define void @clmul_256(<2 x i128> %a128, <2 x i128> %b128, <4 x i64> %a64, <4 x i64> %b64, <8 x i32> %a32, <8 x i32> %b32, <16 x i16> %a16, <16 x i16> %b16, <32 x i8> %a8, <32 x i8> %b8) {
-; PCLMUL-LABEL: 'clmul_256'
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:12 CodeSize:16 Lat:48 SizeLat:32 for: %call_i128 = call <2 x i128> @llvm.clmul.v2i128(<2 x i128> %a128, <2 x i128> %b128)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:6 CodeSize:8 Lat:24 SizeLat:16 for: %call_i64 = call <4 x i64> @llvm.clmul.v4i64(<4 x i64> %a64, <4 x i64> %b64)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:16 CodeSize:24 Lat:36 SizeLat:32 for: %call_i32 = call <8 x i32> @llvm.clmul.v8i32(<8 x i32> %a32, <8 x i32> %b32)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:96 CodeSize:96 Lat:160 SizeLat:96 for: %call_i16 = call <16 x i16> @llvm.clmul.v16i16(<16 x i16> %a16, <16 x i16> %b16)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:80 CodeSize:96 Lat:80 SizeLat:96 for: %call_i8 = call <32 x i8> @llvm.clmul.v32i8(<32 x i8> %a8, <32 x i8> %b8)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+; PCLMUL128-LABEL: 'clmul_256'
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:12 CodeSize:16 Lat:48 SizeLat:32 for: %call_i128 = call <2 x i128> @llvm.clmul.v2i128(<2 x i128> %a128, <2 x i128> %b128)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:6 CodeSize:8 Lat:24 SizeLat:16 for: %call_i64 = call <4 x i64> @llvm.clmul.v4i64(<4 x i64> %a64, <4 x i64> %b64)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:16 CodeSize:24 Lat:36 SizeLat:32 for: %call_i32 = call <8 x i32> @llvm.clmul.v8i32(<8 x i32> %a32, <8 x i32> %b32)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:96 CodeSize:96 Lat:160 SizeLat:96 for: %call_i16 = call <16 x i16> @llvm.clmul.v16i16(<16 x i16> %a16, <16 x i16> %b16)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:80 CodeSize:96 Lat:80 SizeLat:96 for: %call_i8 = call <32 x i8> @llvm.clmul.v32i8(<32 x i8> %a8, <32 x i8> %b8)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; VPCLMULQDQ-LABEL: 'clmul_256'
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:12 CodeSize:16 Lat:48 SizeLat:32 for: %call_i128 = call <2 x i128> @llvm.clmul.v2i128(<2 x i128> %a128, <2 x i128> %b128)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of 2 for: %call_i64 = call <4 x i64> @llvm.clmul.v4i64(<4 x i64> %a64, <4 x i64> %b64)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of 2 for: %call_i32 = call <8 x i32> @llvm.clmul.v8i32(<8 x i32> %a32, <8 x i32> %b32)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:96 CodeSize:112 Lat:112 SizeLat:160 for: %call_i16 = call <16 x i16> @llvm.clmul.v16i16(<16 x i16> %a16, <16 x i16> %b16)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:72 CodeSize:80 Lat:56 SizeLat:96 for: %call_i8 = call <32 x i8> @llvm.clmul.v32i8(<32 x i8> %a8, <32 x i8> %b8)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
 ;
 ; NO-PCLMUL-LABEL: 'clmul_256'
 ; NO-PCLMUL-NEXT:  Cost Model: Found costs of RThru:1536 CodeSize:1536 Lat:1152 SizeLat:1152 for: %call_i128 = call <2 x i128> @llvm.clmul.v2i128(<2 x i128> %a128, <2 x i128> %b128)
@@ -79,13 +96,21 @@ define void @clmul_256(<2 x i128> %a128, <2 x i128> %b128, <4 x i64> %a64, <4 x
 }
 
 define void @clmul_512(<4 x i128> %a128, <4 x i128> %b128, <8 x i64> %a64, <8 x i64> %b64, <16 x i32> %a32, <16 x i32> %b32, <32 x i16> %a16, <32 x i16> %b16, <64 x i8> %a8, <64 x i8> %b8) {
-; PCLMUL-LABEL: 'clmul_512'
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:24 CodeSize:32 Lat:96 SizeLat:64 for: %call_i128 = call <4 x i128> @llvm.clmul.v4i128(<4 x i128> %a128, <4 x i128> %b128)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:12 CodeSize:16 Lat:48 SizeLat:32 for: %call_i64 = call <8 x i64> @llvm.clmul.v8i64(<8 x i64> %a64, <8 x i64> %b64)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:32 CodeSize:48 Lat:72 SizeLat:64 for: %call_i32 = call <16 x i32> @llvm.clmul.v16i32(<16 x i32> %a32, <16 x i32> %b32)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:192 CodeSize:192 Lat:320 SizeLat:192 for: %call_i16 = call <32 x i16> @llvm.clmul.v32i16(<32 x i16> %a16, <32 x i16> %b16)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:160 CodeSize:192 Lat:160 SizeLat:192 for: %call_i8 = call <64 x i8> @llvm.clmul.v64i8(<64 x i8> %a8, <64 x i8> %b8)
-; PCLMUL-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+; PCLMUL128-LABEL: 'clmul_512'
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:24 CodeSize:32 Lat:96 SizeLat:64 for: %call_i128 = call <4 x i128> @llvm.clmul.v4i128(<4 x i128> %a128, <4 x i128> %b128)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:12 CodeSize:16 Lat:48 SizeLat:32 for: %call_i64 = call <8 x i64> @llvm.clmul.v8i64(<8 x i64> %a64, <8 x i64> %b64)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:32 CodeSize:48 Lat:72 SizeLat:64 for: %call_i32 = call <16 x i32> @llvm.clmul.v16i32(<16 x i32> %a32, <16 x i32> %b32)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:192 CodeSize:192 Lat:320 SizeLat:192 for: %call_i16 = call <32 x i16> @llvm.clmul.v32i16(<32 x i16> %a16, <32 x i16> %b16)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:160 CodeSize:192 Lat:160 SizeLat:192 for: %call_i8 = call <64 x i8> @llvm.clmul.v64i8(<64 x i8> %a8, <64 x i8> %b8)
+; PCLMUL128-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; VPCLMULQDQ-LABEL: 'clmul_512'
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:24 CodeSize:32 Lat:96 SizeLat:64 for: %call_i128 = call <4 x i128> @llvm.clmul.v4i128(<4 x i128> %a128, <4 x i128> %b128)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of 4 for: %call_i64 = call <8 x i64> @llvm.clmul.v8i64(<8 x i64> %a64, <8 x i64> %b64)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of 4 for: %call_i32 = call <16 x i32> @llvm.clmul.v16i32(<16 x i32> %a32, <16 x i32> %b32)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:192 CodeSize:224 Lat:224 SizeLat:320 for: %call_i16 = call <32 x i16> @llvm.clmul.v32i16(<32 x i16> %a16, <32 x i16> %b16)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:144 CodeSize:160 Lat:112 SizeLat:192 for: %call_i8 = call <64 x i8> @llvm.clmul.v64i8(<64 x i8> %a8, <64 x i8> %b8)
+; VPCLMULQDQ-NEXT:  Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
 ;
 ; NO-PCLMUL-LABEL: 'clmul_512'
 ; NO-PCLMUL-NEXT:  Cost Model: Found costs of RThru:3072 CodeSize:3072 Lat:2176 SizeLat:2176 for: %call_i128 = call <4 x i128> @llvm.clmul.v4i128(<4 x i128> %a128, <4 x i128> %b128)



More information about the llvm-commits mailing list