[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
arsenm wrote: ### Merge activity * **Jun 17, 10:54 PM UTC**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/141947). https://github.com/llvm/llvm-project/pull/141947 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/arsenm updated
https://github.com/llvm/llvm-project/pull/141947
>From 5179de7f8a6024d25b5a89deadec96894749287e Mon Sep 17 00:00:00 2001
From: Matt Arsenault
Date: Thu, 29 May 2025 15:29:57 +0200
Subject: [PATCH] AMDGPU: Add baseline cost model tests for special argument
intrinsics
---
.../AMDGPU/special-argument-intrinsics.ll | 202 ++
1 file changed, 202 insertions(+)
create mode 100644
llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
new file mode 100644
index 0..ea045e04310be
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
@@ -0,0 +1,202 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID
%s
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=ALL,PACKEDID %s
+
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck
-check-prefixes=SIZE,SIZE-UNPACKEDID %s
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=SIZE,SIZE-PACKEDID %s
+
+define i32 @workitem_id_x() {
+; ALL-LABEL: 'workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_y() {
+; ALL-LABEL: 'workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_z() {
+; ALL-LABEL: 'workitem_id_z'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_z'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/arsenm updated
https://github.com/llvm/llvm-project/pull/141947
>From 5179de7f8a6024d25b5a89deadec96894749287e Mon Sep 17 00:00:00 2001
From: Matt Arsenault
Date: Thu, 29 May 2025 15:29:57 +0200
Subject: [PATCH] AMDGPU: Add baseline cost model tests for special argument
intrinsics
---
.../AMDGPU/special-argument-intrinsics.ll | 202 ++
1 file changed, 202 insertions(+)
create mode 100644
llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
new file mode 100644
index 0..ea045e04310be
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
@@ -0,0 +1,202 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID
%s
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=ALL,PACKEDID %s
+
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck
-check-prefixes=SIZE,SIZE-UNPACKEDID %s
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=SIZE,SIZE-PACKEDID %s
+
+define i32 @workitem_id_x() {
+; ALL-LABEL: 'workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_y() {
+; ALL-LABEL: 'workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_z() {
+; ALL-LABEL: 'workitem_id_z'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_z'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/arsenm updated
https://github.com/llvm/llvm-project/pull/141947
>From 4497b8d17e9aa65d0eccb13a179a6dfb544d808d Mon Sep 17 00:00:00 2001
From: Matt Arsenault
Date: Thu, 29 May 2025 15:29:57 +0200
Subject: [PATCH] AMDGPU: Add baseline cost model tests for special argument
intrinsics
---
.../AMDGPU/special-argument-intrinsics.ll | 202 ++
1 file changed, 202 insertions(+)
create mode 100644
llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
new file mode 100644
index 0..ea045e04310be
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
@@ -0,0 +1,202 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID
%s
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=ALL,PACKEDID %s
+
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck
-check-prefixes=SIZE,SIZE-UNPACKEDID %s
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=SIZE,SIZE-PACKEDID %s
+
+define i32 @workitem_id_x() {
+; ALL-LABEL: 'workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_y() {
+; ALL-LABEL: 'workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_z() {
+; ALL-LABEL: 'workitem_id_z'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_z'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/rampitec approved this pull request. https://github.com/llvm/llvm-project/pull/141947 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/141947 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
llvmbot wrote:
@llvm/pr-subscribers-backend-amdgpu
Author: Matt Arsenault (arsenm)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/141947.diff
1 Files Affected:
- (added) llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
(+202)
``diff
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
new file mode 100644
index 0..ea045e04310be
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
@@ -0,0 +1,202 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID
%s
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=ALL,PACKEDID %s
+
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck
-check-prefixes=SIZE,SIZE-UNPACKEDID %s
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=SIZE,SIZE-PACKEDID %s
+
+define i32 @workitem_id_x() {
+; ALL-LABEL: 'workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_y() {
+; ALL-LABEL: 'workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_z() {
+; ALL-LABEL: 'workitem_id_z'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_z'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workit
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
arsenm wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/141947?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#141948** https://app.graphite.dev/github/pr/llvm/llvm-project/141948?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141947** https://app.graphite.dev/github/pr/llvm/llvm-project/141947?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/141947?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#141946** https://app.graphite.dev/github/pr/llvm/llvm-project/141946?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141945** https://app.graphite.dev/github/pr/llvm/llvm-project/141945?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141944** https://app.graphite.dev/github/pr/llvm/llvm-project/141944?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141943** https://app.graphite.dev/github/pr/llvm/llvm-project/141943?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141904** https://app.graphite.dev/github/pr/llvm/llvm-project/141904?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#141903** https://app.graphite.dev/github/pr/llvm/llvm-project/141903?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/141947 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] AMDGPU: Add baseline cost model tests for special argument intrinsics (PR #141947)
https://github.com/arsenm created
https://github.com/llvm/llvm-project/pull/141947
None
>From 4cd96adeae2b54b0894ca5ae77b4bcb4f1a19a23 Mon Sep 17 00:00:00 2001
From: Matt Arsenault
Date: Thu, 29 May 2025 15:29:57 +0200
Subject: [PATCH] AMDGPU: Add baseline cost model tests for special argument
intrinsics
---
.../AMDGPU/special-argument-intrinsics.ll | 202 ++
1 file changed, 202 insertions(+)
create mode 100644
llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
new file mode 100644
index 0..ea045e04310be
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AMDGPU/special-argument-intrinsics.ll
@@ -0,0 +1,202 @@
+; NOTE: Assertions have been autogenerated by
utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID
%s
+; RUN: opt -passes='print' 2>&1 -disable-output
-mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=ALL,PACKEDID %s
+
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck
-check-prefixes=SIZE,SIZE-UNPACKEDID %s
+; RUN: opt -passes='print' -cost-kind=code-size 2>&1
-disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck
-check-prefixes=SIZE,SIZE-PACKEDID %s
+
+define i32 @workitem_id_x() {
+; ALL-LABEL: 'workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_x'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.x()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_x'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.x()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.x()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_y() {
+; ALL-LABEL: 'workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
i32 %result
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ ret i32 %result
+}
+
+define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) {
+; ALL-LABEL: 'kernel_workitem_id_y'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
void
+;
+; SIZE-LABEL: 'kernel_workitem_id_y'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workitem.id.y()
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store
i32 %result, ptr addrspace(1) %ptr, align 4
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret
void
+;
+ %result = call i32 @llvm.amdgcn.workitem.id.y()
+ store i32 %result, ptr addrspace(1) %ptr
+ ret void
+}
+
+define i32 @workitem_id_z() {
+; ALL-LABEL: 'workitem_id_z'
+; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result
= call i32 @llvm.amdgcn.workitem.id.y()
+; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret
i32 %result
+;
+; SIZE-LABEL: 'workitem_id_z'
+; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction:
%result = call i32 @llvm.amdgcn.workite
