1 ; RUN: llc -mtriple=amdgcn -mcpu=gfx900 < %s | FileCheck %s --check-prefixes=GCN,GFX9
2 ; RUN: llc -mtriple=amdgcn -mcpu=gfx1030 < %s | FileCheck %s --check-prefixes=GCN,GFX10
4 @lds.0 = internal addrspace(3) global [64 x float] poison, align 16
5 @lds.1 = internal addrspace(3) global [64 x float] poison, align 16
6 @lds.2 = internal addrspace(3) global [64 x float] poison, align 16
7 @lds.3 = internal addrspace(3) global [64 x float] poison, align 16
8 @lds.4 = internal addrspace(3) global [64 x float] poison, align 16
9 @lds.5 = internal addrspace(3) global [64 x float] poison, align 16
10 @lds.6 = internal addrspace(3) global [64 x float] poison, align 16
11 @lds.7 = internal addrspace(3) global [64 x float] poison, align 16
12 @lds.8 = internal addrspace(3) global [64 x float] poison, align 16
13 @lds.9 = internal addrspace(3) global [64 x float] poison, align 16
15 declare void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) nocapture, i32 %size, i32 %voffset, i32 %soffset, i32 %offset, i32 %aux)
16 declare void @llvm.amdgcn.global.load.lds(ptr addrspace(1) nocapture %gptr, ptr addrspace(3) nocapture %lptr, i32 %size, i32 %offset, i32 %aux)
18 ; GCN-LABEL: {{^}}buffer_load_lds_dword_2_arrays:
19 ; GCN-COUNT-4: buffer_load_dword
20 ; GCN: s_waitcnt vmcnt(2)
22 ; GCN: s_waitcnt vmcnt(0)
24 define amdgpu_kernel void @buffer_load_lds_dword_2_arrays(<4 x i32> %rsrc, i32 %i1, i32 %i2, ptr addrspace(1) %out) {
26 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.0, i32 4, i32 0, i32 0, i32 0, i32 0)
27 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.0, i32 4, i32 4, i32 0, i32 0, i32 0)
28 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.1, i32 4, i32 8, i32 0, i32 0, i32 0)
29 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.1, i32 4, i32 12, i32 0, i32 0, i32 0)
30 %gep.0 = getelementptr float, ptr addrspace(3) @lds.0, i32 %i1
31 %gep.1 = getelementptr float, ptr addrspace(3) @lds.1, i32 %i2
32 %val.0 = load float, ptr addrspace(3) %gep.0, align 4
33 call void @llvm.amdgcn.wave.barrier()
34 %val.1 = load float, ptr addrspace(3) %gep.1, align 4
35 %tmp.0 = insertelement <2 x float> undef, float %val.0, i32 0
36 %res = insertelement <2 x float> %tmp.0, float %val.1, i32 1
37 store <2 x float> %res, ptr addrspace(1) %out
41 ; On gfx9 if there is a pending FLAT operation, and this is a VMem or LGKM
42 ; waitcnt and the target can report early completion, then we need to force a waitcnt 0.
44 ; GCN-LABEL: {{^}}global_load_lds_dword_2_arrays:
45 ; GCN-COUNT-4: global_load_dword
46 ; GFX9: s_waitcnt vmcnt(0)
47 ; GFX9-COUNT-2: ds_read_b32
48 ; GFX10: s_waitcnt vmcnt(2)
50 ; GFX10: s_waitcnt vmcnt(0)
52 define amdgpu_kernel void @global_load_lds_dword_2_arrays(ptr addrspace(1) nocapture %gptr, i32 %i1, i32 %i2, ptr addrspace(1) %out) {
54 call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) %gptr, ptr addrspace(3) @lds.0, i32 4, i32 0, i32 0)
55 call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) %gptr, ptr addrspace(3) @lds.0, i32 4, i32 4, i32 0)
56 call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) %gptr, ptr addrspace(3) @lds.1, i32 4, i32 8, i32 0)
57 call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) %gptr, ptr addrspace(3) @lds.1, i32 4, i32 12, i32 0)
58 %gep.0 = getelementptr float, ptr addrspace(3) @lds.0, i32 %i1
59 %gep.1 = getelementptr float, ptr addrspace(3) @lds.1, i32 %i2
60 %val.0 = load float, ptr addrspace(3) %gep.0, align 4
61 call void @llvm.amdgcn.wave.barrier()
62 %val.1 = load float, ptr addrspace(3) %gep.1, align 4
63 %tmp.0 = insertelement <2 x float> undef, float %val.0, i32 0
64 %res = insertelement <2 x float> %tmp.0, float %val.1, i32 1
65 store <2 x float> %res, ptr addrspace(1) %out
69 ; There are 8 pseudo registers defined to track LDS DMA dependencies.
70 ; When exhausted we default to vmcnt(0).
72 ; GCN-LABEL: {{^}}buffer_load_lds_dword_10_arrays:
73 ; GCN-COUNT-10: buffer_load_dword
74 ; GCN: s_waitcnt vmcnt(8)
76 ; GCN: s_waitcnt vmcnt(7)
78 ; GCN: s_waitcnt vmcnt(6)
80 ; GCN: s_waitcnt vmcnt(5)
82 ; GCN: s_waitcnt vmcnt(4)
84 ; GCN: s_waitcnt vmcnt(3)
86 ; GCN: s_waitcnt vmcnt(2)
87 ; GCN-NOT: s_waitcnt vmcnt
89 ; GCN: s_waitcnt vmcnt(0)
91 define amdgpu_kernel void @buffer_load_lds_dword_10_arrays(<4 x i32> %rsrc, i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, i32 %i9, ptr addrspace(1) %out) {
93 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.0, i32 4, i32 0, i32 0, i32 0, i32 0)
94 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.1, i32 4, i32 0, i32 0, i32 0, i32 0)
95 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.2, i32 4, i32 0, i32 0, i32 0, i32 0)
96 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.3, i32 4, i32 0, i32 0, i32 0, i32 0)
97 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.4, i32 4, i32 0, i32 0, i32 0, i32 0)
98 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.5, i32 4, i32 0, i32 0, i32 0, i32 0)
99 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.6, i32 4, i32 0, i32 0, i32 0, i32 0)
100 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.7, i32 4, i32 0, i32 0, i32 0, i32 0)
101 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.8, i32 4, i32 0, i32 0, i32 0, i32 0)
102 call void @llvm.amdgcn.raw.buffer.load.lds(<4 x i32> %rsrc, ptr addrspace(3) @lds.9, i32 4, i32 0, i32 0, i32 0, i32 0)
103 %gep.0 = getelementptr float, ptr addrspace(3) @lds.0, i32 %i1
104 %gep.1 = getelementptr float, ptr addrspace(3) @lds.1, i32 %i2
105 %gep.2 = getelementptr float, ptr addrspace(3) @lds.2, i32 %i2
106 %gep.3 = getelementptr float, ptr addrspace(3) @lds.3, i32 %i2
107 %gep.4 = getelementptr float, ptr addrspace(3) @lds.4, i32 %i2
108 %gep.5 = getelementptr float, ptr addrspace(3) @lds.5, i32 %i2
109 %gep.6 = getelementptr float, ptr addrspace(3) @lds.6, i32 %i2
110 %gep.7 = getelementptr float, ptr addrspace(3) @lds.7, i32 %i2
111 %gep.8 = getelementptr float, ptr addrspace(3) @lds.8, i32 %i2
112 %gep.9 = getelementptr float, ptr addrspace(3) @lds.9, i32 %i2
113 %val.0 = load float, ptr addrspace(3) %gep.0, align 4
114 call void @llvm.amdgcn.wave.barrier()
115 %val.1 = load float, ptr addrspace(3) %gep.1, align 4
116 call void @llvm.amdgcn.wave.barrier()
117 %val.2 = load float, ptr addrspace(3) %gep.2, align 4
118 call void @llvm.amdgcn.wave.barrier()
119 %val.3 = load float, ptr addrspace(3) %gep.3, align 4
120 call void @llvm.amdgcn.wave.barrier()
121 %val.4 = load float, ptr addrspace(3) %gep.4, align 4
122 call void @llvm.amdgcn.wave.barrier()
123 %val.5 = load float, ptr addrspace(3) %gep.5, align 4
124 call void @llvm.amdgcn.wave.barrier()
125 %val.6 = load float, ptr addrspace(3) %gep.6, align 4
126 call void @llvm.amdgcn.wave.barrier()
127 %val.7 = load float, ptr addrspace(3) %gep.7, align 4
128 call void @llvm.amdgcn.wave.barrier()
129 %val.8 = load float, ptr addrspace(3) %gep.8, align 4
130 call void @llvm.amdgcn.wave.barrier()
131 %val.9 = load float, ptr addrspace(3) %gep.9, align 4
132 %out.gep.1 = getelementptr float, ptr addrspace(1) %out, i32 1
133 %out.gep.2 = getelementptr float, ptr addrspace(1) %out, i32 2
134 %out.gep.3 = getelementptr float, ptr addrspace(1) %out, i32 3
135 %out.gep.4 = getelementptr float, ptr addrspace(1) %out, i32 4
136 %out.gep.5 = getelementptr float, ptr addrspace(1) %out, i32 5
137 %out.gep.6 = getelementptr float, ptr addrspace(1) %out, i32 6
138 %out.gep.7 = getelementptr float, ptr addrspace(1) %out, i32 7
139 %out.gep.8 = getelementptr float, ptr addrspace(1) %out, i32 8
140 %out.gep.9 = getelementptr float, ptr addrspace(1) %out, i32 9
141 store float %val.0, ptr addrspace(1) %out
142 store float %val.1, ptr addrspace(1) %out.gep.1
143 store float %val.2, ptr addrspace(1) %out.gep.2
144 store float %val.3, ptr addrspace(1) %out.gep.3
145 store float %val.4, ptr addrspace(1) %out.gep.4
146 store float %val.5, ptr addrspace(1) %out.gep.5
147 store float %val.6, ptr addrspace(1) %out.gep.6
148 store float %val.7, ptr addrspace(1) %out.gep.7
149 store float %val.8, ptr addrspace(1) %out.gep.8
150 store float %val.9, ptr addrspace(1) %out.gep.9
154 declare void @llvm.amdgcn.wave.barrier()