1 ; RUN: llc -mtriple=amdgcn -mattr=-promote-alloca,+max-private-element-size-16 -verify-machineinstrs < %s | FileCheck --check-prefixes=SI-ALLOCA16,SI %s
2 ; RUN: llc -mtriple=amdgcn -mattr=-promote-alloca,+max-private-element-size-4 -verify-machineinstrs < %s | FileCheck --check-prefixes=SI-ALLOCA4,SI %s
3 ; RUN: llc -mtriple=amdgcn -mattr=+promote-alloca -disable-promote-alloca-to-vector -verify-machineinstrs < %s | FileCheck --check-prefixes=SI-PROMOTE,SI %s
4 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global -mattr=-promote-alloca,+max-private-element-size-16 -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
5 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global -mattr=+promote-alloca -disable-promote-alloca-to-vector -verify-machineinstrs < %s | FileCheck --check-prefixes=CI-PROMOTE,SI %s
7 declare void @llvm.amdgcn.s.barrier() #0
9 ; SI-LABEL: {{^}}private_access_f64_alloca:
11 ; SI-ALLOCA16: buffer_store_dwordx2
12 ; SI-ALLOCA16: buffer_load_dwordx2
14 ; SI-ALLOCA4: buffer_store_dword v
15 ; SI-ALLOCA4: buffer_store_dword v
16 ; SI-ALLOCA4: buffer_load_dword v
17 ; SI-ALLOCA4: buffer_load_dword v
19 ; SI-PROMOTE: ds_write_b64
20 ; SI-PROMOTE: ds_read_b64
21 ; CI-PROMOTE: ds_write_b64
22 ; CI-PROMOTE: ds_read_b64
23 define amdgpu_kernel void @private_access_f64_alloca(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, i32 %b) #1 {
24 %val = load double, ptr addrspace(1) %in, align 8
25 %array = alloca [8 x double], align 8, addrspace(5)
26 %ptr = getelementptr inbounds [8 x double], ptr addrspace(5) %array, i32 0, i32 %b
27 store double %val, ptr addrspace(5) %ptr, align 8
28 call void @llvm.amdgcn.s.barrier()
29 %result = load double, ptr addrspace(5) %ptr, align 8
30 store double %result, ptr addrspace(1) %out, align 8
34 ; SI-LABEL: {{^}}private_access_v2f64_alloca:
36 ; SI-ALLOCA16: buffer_store_dwordx4
37 ; SI-ALLOCA16: buffer_load_dwordx4
39 ; SI-ALLOCA4: buffer_store_dword v
40 ; SI-ALLOCA4: buffer_store_dword v
41 ; SI-ALLOCA4: buffer_store_dword v
42 ; SI-ALLOCA4: buffer_store_dword v
43 ; SI-ALLOCA4: buffer_load_dword v
44 ; SI-ALLOCA4: buffer_load_dword v
45 ; SI-ALLOCA4: buffer_load_dword v
46 ; SI-ALLOCA4: buffer_load_dword v
48 ; SI-PROMOTE: ds_write_b64
49 ; SI-PROMOTE: ds_write_b64
50 ; SI-PROMOTE: ds_read_b64
51 ; SI-PROMOTE: ds_read_b64
52 ; CI-PROMOTE: ds_write_b128
53 ; CI-PROMOTE: ds_read_b128
54 define amdgpu_kernel void @private_access_v2f64_alloca(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, i32 %b) #1 {
55 %val = load <2 x double>, ptr addrspace(1) %in, align 16
56 %array = alloca [4 x <2 x double>], align 16, addrspace(5)
57 %ptr = getelementptr inbounds [4 x <2 x double>], ptr addrspace(5) %array, i32 0, i32 %b
58 store <2 x double> %val, ptr addrspace(5) %ptr, align 16
59 call void @llvm.amdgcn.s.barrier()
60 %result = load <2 x double>, ptr addrspace(5) %ptr, align 16
61 store <2 x double> %result, ptr addrspace(1) %out, align 16
65 ; SI-LABEL: {{^}}private_access_i64_alloca:
67 ; SI-ALLOCA16: buffer_store_dwordx2
68 ; SI-ALLOCA16: buffer_load_dwordx2
70 ; SI-ALLOCA4: buffer_store_dword v
71 ; SI-ALLOCA4: buffer_store_dword v
72 ; SI-ALLOCA4: buffer_load_dword v
73 ; SI-ALLOCA4: buffer_load_dword v
76 ; SI-PROMOTE: ds_write_b64
77 ; SI-PROMOTE: ds_read_b64
78 ; CI-PROMOTE: ds_write_b64
79 ; CI-PROMOTE: ds_read_b64
80 define amdgpu_kernel void @private_access_i64_alloca(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, i32 %b) #1 {
81 %val = load i64, ptr addrspace(1) %in, align 8
82 %array = alloca [8 x i64], align 8, addrspace(5)
83 %ptr = getelementptr inbounds [8 x i64], ptr addrspace(5) %array, i32 0, i32 %b
84 store i64 %val, ptr addrspace(5) %ptr, align 8
85 call void @llvm.amdgcn.s.barrier()
86 %result = load i64, ptr addrspace(5) %ptr, align 8
87 store i64 %result, ptr addrspace(1) %out, align 8
91 ; SI-LABEL: {{^}}private_access_v2i64_alloca:
93 ; SI-ALLOCA16: buffer_store_dwordx4
94 ; SI-ALLOCA16: buffer_load_dwordx4
96 ; SI-ALLOCA4: buffer_store_dword v
97 ; SI-ALLOCA4: buffer_store_dword v
98 ; SI-ALLOCA4: buffer_store_dword v
99 ; SI-ALLOCA4: buffer_store_dword v
101 ; SI-ALLOCA4: buffer_load_dword v
102 ; SI-ALLOCA4: buffer_load_dword v
103 ; SI-ALLOCA4: buffer_load_dword v
104 ; SI-ALLOCA4: buffer_load_dword v
106 ; SI-PROMOTE: ds_write_b64
107 ; SI-PROMOTE: ds_write_b64
108 ; SI-PROMOTE: ds_read_b64
109 ; SI-PROMOTE: ds_read_b64
110 ; CI-PROMOTE: ds_write_b128
111 ; CI-PROMOTE: ds_read_b128
112 define amdgpu_kernel void @private_access_v2i64_alloca(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, i32 %b) #1 {
113 %val = load <2 x i64>, ptr addrspace(1) %in, align 16
114 %array = alloca [4 x <2 x i64>], align 16, addrspace(5)
115 %ptr = getelementptr inbounds [4 x <2 x i64>], ptr addrspace(5) %array, i32 0, i32 %b
116 store <2 x i64> %val, ptr addrspace(5) %ptr, align 16
117 call void @llvm.amdgcn.s.barrier()
118 %result = load <2 x i64>, ptr addrspace(5) %ptr, align 16
119 store <2 x i64> %result, ptr addrspace(1) %out, align 16
123 attributes #0 = { convergent nounwind }
124 attributes #1 = { nounwind "amdgpu-waves-per-eu"="1,2" "amdgpu-flat-work-group-size"="64,128" }