252
|
1 ; RUN: llc -march=amdgcn -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefix=HSA %s
|
150
|
2
|
|
3 @lds.align16.0 = internal unnamed_addr addrspace(3) global [38 x i8] undef, align 16
|
|
4 @lds.align16.1 = internal unnamed_addr addrspace(3) global [38 x i8] undef, align 16
|
|
5
|
|
6 @lds.align8.0 = internal unnamed_addr addrspace(3) global [38 x i8] undef, align 8
|
|
7 @lds.align32.0 = internal unnamed_addr addrspace(3) global [38 x i8] undef, align 32
|
|
8
|
|
9 @lds.missing.align.0 = internal unnamed_addr addrspace(3) global [39 x i32] undef
|
|
10 @lds.missing.align.1 = internal unnamed_addr addrspace(3) global [7 x i64] undef
|
|
11
|
252
|
12 declare void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) nocapture, ptr addrspace(1) nocapture readonly, i32, i1) #0
|
|
13 declare void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) nocapture, ptr addrspace(3) nocapture readonly, i32, i1) #0
|
150
|
14
|
|
15
|
|
16 ; HSA-LABEL: {{^}}test_no_round_size_1:
|
|
17 ; HSA: workgroup_group_segment_byte_size = 38
|
252
|
18 define amdgpu_kernel void @test_no_round_size_1(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
19 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.align16.0, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
|
20 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.align16.0, i32 38, i1 false)
|
150
|
21 ret void
|
|
22 }
|
|
23
|
|
24 ; There are two objects, so one requires padding to be correctly
|
|
25 ; aligned after the other.
|
|
26
|
|
27 ; (38 -> 48) + 38 = 92
|
|
28
|
|
29 ; I don't think it is necessary to add padding after since if there
|
|
30 ; were to be a dynamically sized LDS kernel arg, the runtime should
|
|
31 ; add the alignment padding if necessary alignment padding if needed.
|
|
32
|
|
33 ; HSA-LABEL: {{^}}test_round_size_2:
|
|
34 ; HSA: workgroup_group_segment_byte_size = 86
|
|
35 ; HSA: group_segment_alignment = 4
|
252
|
36 define amdgpu_kernel void @test_round_size_2(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
37 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.align16.0, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
|
38 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.align16.0, i32 38, i1 false)
|
150
|
39
|
252
|
40 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.align16.1, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
|
41 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.align16.1, i32 38, i1 false)
|
150
|
42
|
|
43 ret void
|
|
44 }
|
|
45
|
221
|
46 ; 38 + (10 pad) + 38 (= 86)
|
150
|
47 ; HSA-LABEL: {{^}}test_round_size_2_align_8:
|
|
48 ; HSA: workgroup_group_segment_byte_size = 86
|
|
49 ; HSA: group_segment_alignment = 4
|
252
|
50 define amdgpu_kernel void @test_round_size_2_align_8(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
51 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
52 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
53
|
252
|
54 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
55 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
56
|
|
57 ret void
|
|
58 }
|
|
59
|
|
60 ; HSA-LABEL: {{^}}test_round_local_lds_and_arg:
|
|
61 ; HSA: workgroup_group_segment_byte_size = 38
|
|
62 ; HSA: group_segment_alignment = 4
|
252
|
63 define amdgpu_kernel void @test_round_local_lds_and_arg(ptr addrspace(1) %out, ptr addrspace(1) %in, ptr addrspace(3) %lds.arg) #1 {
|
|
64 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.align16.0, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
150
|
65
|
252
|
66 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.align16.0, i32 38, i1 false)
|
|
67 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 %lds.arg, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
|
68 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 %lds.arg, i32 38, i1 false)
|
150
|
69 ret void
|
|
70 }
|
|
71
|
|
72 ; HSA-LABEL: {{^}}test_round_lds_arg:
|
|
73 ; HSA: workgroup_group_segment_byte_size = 0
|
|
74 ; HSA: group_segment_alignment = 4
|
252
|
75 define amdgpu_kernel void @test_round_lds_arg(ptr addrspace(1) %out, ptr addrspace(1) %in, ptr addrspace(3) %lds.arg) #1 {
|
|
76 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 %lds.arg, ptr addrspace(1) align 4 %in, i32 38, i1 false)
|
|
77 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 %lds.arg, i32 38, i1 false)
|
150
|
78 ret void
|
|
79 }
|
|
80
|
|
81 ; FIXME: Parameter alignment not considered
|
|
82 ; HSA-LABEL: {{^}}test_high_align_lds_arg:
|
|
83 ; HSA: workgroup_group_segment_byte_size = 0
|
|
84 ; HSA: group_segment_alignment = 4
|
252
|
85 define amdgpu_kernel void @test_high_align_lds_arg(ptr addrspace(1) %out, ptr addrspace(1) %in, ptr addrspace(3) align 64 %lds.arg) #1 {
|
|
86 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 64 %lds.arg, ptr addrspace(1) align 64 %in, i32 38, i1 false)
|
|
87 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 64 %out, ptr addrspace(3) align 64 %lds.arg, i32 38, i1 false)
|
150
|
88 ret void
|
|
89 }
|
|
90
|
221
|
91 ; (39 * 4) + (4 pad) + (7 * 8) = 216
|
150
|
92 ; HSA-LABEL: {{^}}test_missing_alignment_size_2_order0:
|
221
|
93 ; HSA: workgroup_group_segment_byte_size = 216
|
150
|
94 ; HSA: group_segment_alignment = 4
|
252
|
95 define amdgpu_kernel void @test_missing_alignment_size_2_order0(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
96 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.missing.align.0, ptr addrspace(1) align 4 %in, i32 160, i1 false)
|
|
97 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.missing.align.0, i32 160, i1 false)
|
150
|
98
|
252
|
99 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.missing.align.1, ptr addrspace(1) align 8 %in, i32 56, i1 false)
|
|
100 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.missing.align.1, i32 56, i1 false)
|
150
|
101
|
|
102 ret void
|
|
103 }
|
|
104
|
|
105 ; (39 * 4) + (4 pad) + (7 * 8) = 216
|
|
106 ; HSA-LABEL: {{^}}test_missing_alignment_size_2_order1:
|
|
107 ; HSA: workgroup_group_segment_byte_size = 216
|
|
108 ; HSA: group_segment_alignment = 4
|
252
|
109 define amdgpu_kernel void @test_missing_alignment_size_2_order1(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
110 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.missing.align.1, ptr addrspace(1) align 8 %in, i32 56, i1 false)
|
|
111 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.missing.align.1, i32 56, i1 false)
|
150
|
112
|
252
|
113 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 4 @lds.missing.align.0, ptr addrspace(1) align 4 %in, i32 160, i1 false)
|
|
114 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 4 %out, ptr addrspace(3) align 4 @lds.missing.align.0, i32 160, i1 false)
|
150
|
115
|
|
116 ret void
|
|
117 }
|
|
118
|
221
|
119 ; align 32, 16, 16
|
|
120 ; 38 + (10 pad) + 38 + (10 pad) + 38 ( = 134)
|
150
|
121 ; HSA-LABEL: {{^}}test_round_size_3_order0:
|
|
122 ; HSA: workgroup_group_segment_byte_size = 134
|
|
123 ; HSA: group_segment_alignment = 4
|
252
|
124 define amdgpu_kernel void @test_round_size_3_order0(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
125 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
126 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
127
|
252
|
128 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
129 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
130
|
252
|
131 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
132 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
133
|
|
134 ret void
|
|
135 }
|
|
136
|
221
|
137 ; align 32, 16, 16
|
|
138 ; 38 (+ 10 pad) + 38 + (10 pad) + 38 ( = 134)
|
150
|
139 ; HSA-LABEL: {{^}}test_round_size_3_order1:
|
|
140 ; HSA: workgroup_group_segment_byte_size = 134
|
|
141 ; HSA: group_segment_alignment = 4
|
252
|
142 define amdgpu_kernel void @test_round_size_3_order1(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
143 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
144 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
145
|
252
|
146 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
147 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
148
|
252
|
149 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
150 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
151
|
|
152 ret void
|
|
153 }
|
|
154
|
221
|
155 ; align 32, 16, 16
|
|
156 ; 38 + (10 pad) + 38 + (10 pad) + 38 ( = 126)
|
150
|
157 ; HSA-LABEL: {{^}}test_round_size_3_order2:
|
221
|
158 ; HSA: workgroup_group_segment_byte_size = 134
|
150
|
159 ; HSA: group_segment_alignment = 4
|
252
|
160 define amdgpu_kernel void @test_round_size_3_order2(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
161 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
162 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
163
|
252
|
164 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
165 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
166
|
252
|
167 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
168 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
169
|
|
170 ret void
|
|
171 }
|
|
172
|
221
|
173 ; align 32, 16, 16
|
|
174 ; 38 + (10 pad) + 38 + (10 pad) + 38 ( = 134)
|
150
|
175 ; HSA-LABEL: {{^}}test_round_size_3_order3:
|
221
|
176 ; HSA: workgroup_group_segment_byte_size = 134
|
150
|
177 ; HSA: group_segment_alignment = 4
|
252
|
178 define amdgpu_kernel void @test_round_size_3_order3(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
179 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
180 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
181
|
252
|
182 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
183 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
184
|
252
|
185 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
186 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
187
|
|
188 ret void
|
|
189 }
|
|
190
|
221
|
191 ; align 32, 16, 16
|
|
192 ; 38 + (10 pad) + 38 + (10 pad) + 38 (= 134)
|
150
|
193 ; HSA-LABEL: {{^}}test_round_size_3_order4:
|
221
|
194 ; HSA: workgroup_group_segment_byte_size = 134
|
150
|
195 ; HSA: group_segment_alignment = 4
|
252
|
196 define amdgpu_kernel void @test_round_size_3_order4(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
197 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
198 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
199
|
252
|
200 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
201 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
202
|
252
|
203 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
204 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
205
|
|
206 ret void
|
|
207 }
|
|
208
|
221
|
209 ; align 32, 16, 16
|
|
210 ; 38 + (10 pad) + 38 + (10 pad) + 38 (= 134)
|
150
|
211 ; HSA-LABEL: {{^}}test_round_size_3_order5:
|
221
|
212 ; HSA: workgroup_group_segment_byte_size = 134
|
150
|
213 ; HSA: group_segment_alignment = 4
|
252
|
214 define amdgpu_kernel void @test_round_size_3_order5(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
|
|
215 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align8.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
216 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align8.0, i32 38, i1 false)
|
150
|
217
|
252
|
218 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align16.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
219 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align16.0, i32 38, i1 false)
|
150
|
220
|
252
|
221 call void @llvm.memcpy.p3.p1.i32(ptr addrspace(3) align 8 @lds.align32.0, ptr addrspace(1) align 8 %in, i32 38, i1 false)
|
|
222 call void @llvm.memcpy.p1.p3.i32(ptr addrspace(1) align 8 %out, ptr addrspace(3) align 8 @lds.align32.0, i32 38, i1 false)
|
150
|
223
|
|
224 ret void
|
|
225 }
|
|
226
|
|
227 attributes #0 = { argmemonly nounwind }
|
|
228 attributes #1 = { nounwind }
|
|
229 attributes #2 = { convergent nounwind }
|
252
|
230
|
|
231 !llvm.module.flags = !{!0}
|
|
232 !0 = !{i32 1, !"amdgpu_code_object_version", i32 200}
|