1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-attributor %s | FileCheck %s
4 ; Check propagation of amdgpu-flat-work-group-size attribute.
6 ; Called from a single kernel with 1,256
7 define internal void @default_to_1_256() {
8 ; CHECK-LABEL: define {{[^@]+}}@default_to_1_256
9 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
10 ; CHECK-NEXT: ret void
15 define amdgpu_kernel void @kernel_1_256() #0 {
16 ; CHECK-LABEL: define {{[^@]+}}@kernel_1_256
17 ; CHECK-SAME: () #[[ATTR0]] {
18 ; CHECK-NEXT: call void @default_to_1_256()
19 ; CHECK-NEXT: ret void
21 call void @default_to_1_256()
25 ; Called from a single kernel with 64,128
26 define internal void @default_to_64_128() {
27 ; CHECK-LABEL: define {{[^@]+}}@default_to_64_128
28 ; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
29 ; CHECK-NEXT: ret void
34 define amdgpu_kernel void @kernel_64_128() #1 {
35 ; CHECK-LABEL: define {{[^@]+}}@kernel_64_128
36 ; CHECK-SAME: () #[[ATTR1]] {
37 ; CHECK-NEXT: call void @default_to_64_128()
38 ; CHECK-NEXT: call void @flat_group_64_64()
39 ; CHECK-NEXT: call void @default_to_64_256()
40 ; CHECK-NEXT: call void @flat_group_128_256()
41 ; CHECK-NEXT: ret void
43 call void @default_to_64_128()
44 call void @flat_group_64_64()
45 call void @default_to_64_256()
46 call void @flat_group_128_256()
50 ; Called from kernels with 128,512 and 512,512
51 define internal void @default_to_128_512() {
52 ; CHECK-LABEL: define {{[^@]+}}@default_to_128_512
53 ; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
54 ; CHECK-NEXT: ret void
59 ; This already has a strict bounds, but called from kernels with wider
60 ; bounds, and should not be changed.
61 define internal void @flat_group_64_64() #2 {
62 ; CHECK-LABEL: define {{[^@]+}}@flat_group_64_64
63 ; CHECK-SAME: () #[[ATTR3:[0-9]+]] {
64 ; CHECK-NEXT: ret void
70 define internal void @flat_group_128_256() #3 {
71 ; CHECK-LABEL: define {{[^@]+}}@flat_group_128_256
72 ; CHECK-SAME: () #[[ATTR4:[0-9]+]] {
73 ; CHECK-NEXT: ret void
78 define internal void @flat_group_512_1024() #4 {
79 ; CHECK-LABEL: define {{[^@]+}}@flat_group_512_1024
80 ; CHECK-SAME: () #[[ATTR5:[0-9]+]] {
81 ; CHECK-NEXT: ret void
86 define amdgpu_kernel void @kernel_128_512() #5 {
87 ; CHECK-LABEL: define {{[^@]+}}@kernel_128_512
88 ; CHECK-SAME: () #[[ATTR2]] {
89 ; CHECK-NEXT: call void @default_to_128_512()
90 ; CHECK-NEXT: call void @flat_group_64_64()
91 ; CHECK-NEXT: ret void
93 call void @default_to_128_512()
94 call void @flat_group_64_64()
98 define amdgpu_kernel void @kernel_512_512() #6 {
99 ; CHECK-LABEL: define {{[^@]+}}@kernel_512_512
100 ; CHECK-SAME: () #[[ATTR5]] {
101 ; CHECK-NEXT: call void @default_to_128_512()
102 ; CHECK-NEXT: call void @flat_group_512_1024()
103 ; CHECK-NEXT: ret void
105 call void @default_to_128_512()
106 call void @flat_group_512_1024()
110 ; Called from kernels with 128,256 and 64,128 => 64,256
111 define internal void @default_to_64_256() {
112 ; CHECK-LABEL: define {{[^@]+}}@default_to_64_256
113 ; CHECK-SAME: () #[[ATTR6:[0-9]+]] {
114 ; CHECK-NEXT: ret void
119 ; The kernel's lower bound is higher than the callee's lower bound, so
120 ; this should probably be illegal.
121 define amdgpu_kernel void @kernel_128_256() #3 {
122 ; CHECK-LABEL: define {{[^@]+}}@kernel_128_256
123 ; CHECK-SAME: () #[[ATTR7:[0-9]+]] {
124 ; CHECK-NEXT: call void @default_to_64_256()
125 ; CHECK-NEXT: ret void
127 call void @default_to_64_256()
132 define internal void @merge_cycle_0() #1 {
133 ; CHECK-LABEL: define {{[^@]+}}@merge_cycle_0
134 ; CHECK-SAME: () #[[ATTR1]] {
135 ; CHECK-NEXT: call void @merge_cycle_1()
136 ; CHECK-NEXT: ret void
138 call void @merge_cycle_1()
143 define internal void @merge_cycle_1() #3 {
144 ; CHECK-LABEL: define {{[^@]+}}@merge_cycle_1
145 ; CHECK-SAME: () #[[ATTR4]] {
146 ; CHECK-NEXT: call void @merge_cycle_0()
147 ; CHECK-NEXT: ret void
149 call void @merge_cycle_0()
153 define amdgpu_kernel void @kernel_64_256() #7 {
154 ; CHECK-LABEL: define {{[^@]+}}@kernel_64_256
155 ; CHECK-SAME: () #[[ATTR6]] {
156 ; CHECK-NEXT: call void @merge_cycle_0()
157 ; CHECK-NEXT: call void @default_captured_address()
158 ; CHECK-NEXT: call void @externally_visible_default()
159 ; CHECK-NEXT: [[F32:%.*]] = call float @bitcasted_function()
160 ; CHECK-NEXT: ret void
162 call void @merge_cycle_0()
163 call void @default_captured_address()
164 call void @externally_visible_default()
165 %f32 = call float @bitcasted_function()
169 define internal void @default_captured_address() {
170 ; CHECK-LABEL: define {{[^@]+}}@default_captured_address
171 ; CHECK-SAME: () #[[ATTR8:[0-9]+]] {
172 ; CHECK-NEXT: store volatile ptr @default_captured_address, ptr undef, align 8
173 ; CHECK-NEXT: ret void
175 store volatile ptr @default_captured_address, ptr undef, align 8
179 define void @externally_visible_default() {
180 ; CHECK-LABEL: define {{[^@]+}}@externally_visible_default
181 ; CHECK-SAME: () #[[ATTR8]] {
182 ; CHECK-NEXT: ret void
188 define internal i32 @bitcasted_function() {
189 ; CHECK-LABEL: define {{[^@]+}}@bitcasted_function
190 ; CHECK-SAME: () #[[ATTR6]] {
191 ; CHECK-NEXT: ret i32 0
196 attributes #0 = { "amdgpu-flat-work-group-size"="1,256" }
197 attributes #1 = { "amdgpu-flat-work-group-size"="64,128" }
198 attributes #2 = { "amdgpu-flat-work-group-size"="64,64" }
199 attributes #3 = { "amdgpu-flat-work-group-size"="128,256" }
200 attributes #4 = { "amdgpu-flat-work-group-size"="512,1024" }
201 attributes #5 = { "amdgpu-flat-work-group-size"="128,512" }
202 attributes #6 = { "amdgpu-flat-work-group-size"="512,512" }
203 attributes #7 = { "amdgpu-flat-work-group-size"="64,256" }
205 ; CHECK: attributes #[[ATTR0]] = { "amdgpu-flat-work-group-size"="1,256" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
206 ; CHECK: attributes #[[ATTR1]] = { "amdgpu-flat-work-group-size"="64,128" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
207 ; CHECK: attributes #[[ATTR2]] = { "amdgpu-flat-work-group-size"="128,512" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "amdgpu-waves-per-eu"="2,10" "uniform-work-group-size"="false" }
208 ; CHECK: attributes #[[ATTR3]] = { "amdgpu-flat-work-group-size"="64,64" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
209 ; CHECK: attributes #[[ATTR4]] = { "amdgpu-flat-work-group-size"="128,128" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
210 ; CHECK: attributes #[[ATTR5]] = { "amdgpu-flat-work-group-size"="512,512" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "amdgpu-waves-per-eu"="2,10" "uniform-work-group-size"="false" }
211 ; CHECK: attributes #[[ATTR6]] = { "amdgpu-flat-work-group-size"="64,256" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
212 ; CHECK: attributes #[[ATTR7]] = { "amdgpu-flat-work-group-size"="128,256" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
213 ; CHECK: attributes #[[ATTR8]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }