constant-bus-restriction.ll
9.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GFX9 %s
; RUN: llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GFX10 %s
; Make sure we don't violate the constant bus restriction
define amdgpu_ps float @fmul_s_s(float inreg %src0, float inreg %src1) {
; GFX9-LABEL: fmul_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_mul_f32_e32 v0, s2, v0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fmul_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mul_f32_e64 v0, s2, s3
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = fmul float %src0, %src1
ret float %result
}
define amdgpu_ps float @fmul_ss(float inreg %src) {
; GFX9-LABEL: fmul_ss:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mul_f32_e64 v0, s2, s2
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fmul_ss:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mul_f32_e64 v0, s2, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = fmul float %src, %src
ret float %result
}
; Ternary operation with 3 different SGPRs
define amdgpu_ps float @fma_s_s_s(float inreg %src0, float inreg %src1, float inreg %src2) {
; GFX9-LABEL: fma_s_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_mov_b32_e32 v1, s4
; GFX9-NEXT: v_fma_f32 v0, s2, v0, v1
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fma_s_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mov_b32_e32 v0, s4
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_fma_f32 v0, s3, s2, v0
; GFX10-NEXT: ; return to shader part epilog
%result = call float @llvm.fma.f32(float %src0, float %src1, float %src2)
ret float %result
}
; Ternary operation with 3 identical SGPRs
define amdgpu_ps float @fma_sss(float inreg %src) {
; GFX9-LABEL: fma_sss:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_fma_f32 v0, s2, s2, s2
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fma_sss:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_fma_f32 v0, s2, s2, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = call float @llvm.fma.f32(float %src, float %src, float %src)
ret float %result
}
; src0/1 are same SGPR
define amdgpu_ps float @fma_ss_s(float inreg %src01, float inreg %src2) {
; GFX9-LABEL: fma_ss_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_fma_f32 v0, s2, s2, v0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fma_ss_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_fma_f32 v0, s2, s2, s3
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = call float @llvm.fma.f32(float %src01, float %src01, float %src2)
ret float %result
}
; src1/2 are same SGPR
define amdgpu_ps float @fma_s_ss(float inreg %src0, float inreg %src12) {
; GFX9-LABEL: fma_s_ss:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_fma_f32 v0, s2, v0, v0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fma_s_ss:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_fma_f32 v0, s2, s3, s3
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = call float @llvm.fma.f32(float %src0, float %src12, float %src12)
ret float %result
}
; src0/2 are same SGPR
define amdgpu_ps float @fma_ss_s_same_outer(float inreg %src02, float inreg %src1) {
; GFX9-LABEL: fma_ss_s_same_outer:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_fma_f32 v0, s2, v0, s2
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fma_ss_s_same_outer:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_fma_f32 v0, s2, s3, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%result = call float @llvm.fma.f32(float %src02, float %src1, float %src02)
ret float %result
}
define amdgpu_ps float @fcmp_s_s(float inreg %src0, float inreg %src1) {
; GFX9-LABEL: fcmp_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_cmp_eq_f32_e32 vcc, s2, v0
; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1.0, vcc
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: fcmp_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_cmp_eq_f32_e64 s0, s2, s3
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1.0, s0
; GFX10-NEXT: ; return to shader part epilog
%cmp = fcmp oeq float %src0, %src1
%result = select i1 %cmp, float 1.0, float 0.0
ret float %result
}
define amdgpu_ps float @select_vcc_s_s(float %cmp0, float %cmp1, float inreg %src0, float inreg %src1) {
; GFX9-LABEL: select_vcc_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v2, s2
; GFX9-NEXT: v_mov_b32_e32 v3, s3
; GFX9-NEXT: v_cmp_eq_f32_e32 vcc, v0, v1
; GFX9-NEXT: v_cndmask_b32_e32 v0, v3, v2, vcc
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: select_vcc_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mov_b32_e32 v2, s3
; GFX10-NEXT: v_cmp_eq_f32_e32 vcc_lo, v0, v1
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_cndmask_b32_e64 v0, v2, s2, vcc_lo
; GFX10-NEXT: ; return to shader part epilog
%cmp = fcmp oeq float %cmp0, %cmp1
%result = select i1 %cmp, float %src0, float %src1
ret float %result
}
define amdgpu_ps float @select_vcc_fneg_s_s(float %cmp0, float %cmp1, float inreg %src0, float inreg %src1) {
; GFX9-LABEL: select_vcc_fneg_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v2, s3
; GFX9-NEXT: v_mov_b32_e32 v3, s2
; GFX9-NEXT: v_cmp_eq_f32_e32 vcc, v0, v1
; GFX9-NEXT: v_cndmask_b32_e64 v0, v2, -v3, vcc
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: select_vcc_fneg_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_mov_b32_e32 v2, s2
; GFX10-NEXT: v_cmp_eq_f32_e32 vcc_lo, v0, v1
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_cndmask_b32_e64 v0, s3, -v2, vcc_lo
; GFX10-NEXT: ; return to shader part epilog
%cmp = fcmp oeq float %cmp0, %cmp1
%neg.src0 = fneg float %src0
%result = select i1 %cmp, float %neg.src0, float %src1
ret float %result
}
; Constant bus used by vcc
define amdgpu_ps float @amdgcn_div_fmas_sss(float inreg %src, float %cmp.src) {
; GFX9-LABEL: amdgcn_div_fmas_sss:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_cmp_eq_f32_e32 vcc, 0, v0
; GFX9-NEXT: v_mov_b32_e32 v0, s2
; GFX9-NEXT: s_nop 2
; GFX9-NEXT: v_div_fmas_f32 v0, v0, v0, v0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: amdgcn_div_fmas_sss:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_cmp_eq_f32_e32 vcc_lo, 0, v0
; GFX10-NEXT: v_div_fmas_f32 v0, s2, s2, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%vcc = fcmp oeq float %cmp.src, 0.0
%result = call float @llvm.amdgcn.div.fmas.f32(float %src, float %src, float %src, i1 %vcc)
ret float %result
}
define amdgpu_ps float @class_s_s(float inreg %src0, i32 inreg %src1) {
; GFX9-LABEL: class_s_s:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_cmp_class_f32_e32 vcc, s2, v0
; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1.0, vcc
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: class_s_s:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_cmp_class_f32_e64 s0, s2, s3
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1.0, s0
; GFX10-NEXT: ; return to shader part epilog
%class = call i1 @llvm.amdgcn.class.f32(float %src0, i32 %src1)
%result = select i1 %class, float 1.0, float 0.0
ret float %result
}
define amdgpu_ps float @div_scale_s_s_true(float inreg %src0, float inreg %src1) {
; GFX9-LABEL: div_scale_s_s_true:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_div_scale_f32 v0, s[0:1], s2, v0, s2
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: div_scale_s_s_true:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_div_scale_f32 v0, s0, s2, s3, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%div.scale = call { float, i1 } @llvm.amdgcn.div.scale.f32(float %src0, float %src1, i1 true)
%result = extractvalue { float, i1 } %div.scale, 0
ret float %result
}
define amdgpu_ps float @div_scale_s_s_false(float inreg %src0, float inreg %src1) {
; GFX9-LABEL: div_scale_s_s_false:
; GFX9: ; %bb.0:
; GFX9-NEXT: v_mov_b32_e32 v0, s3
; GFX9-NEXT: v_div_scale_f32 v0, s[0:1], v0, v0, s2
; GFX9-NEXT: ; return to shader part epilog
;
; GFX10-LABEL: div_scale_s_s_false:
; GFX10: ; %bb.0:
; GFX10-NEXT: v_div_scale_f32 v0, s0, s3, s3, s2
; GFX10-NEXT: ; implicit-def: $vcc_hi
; GFX10-NEXT: ; return to shader part epilog
%div.scale = call { float, i1 } @llvm.amdgcn.div.scale.f32(float %src0, float %src1, i1 false)
%result = extractvalue { float, i1 } %div.scale, 0
ret float %result
}
declare float @llvm.fma.f32(float, float, float) #0
declare float @llvm.amdgcn.div.fmas.f32(float, float, float, i1) #1
declare { float, i1 } @llvm.amdgcn.div.scale.f32(float, float, i1 immarg) #1
declare i1 @llvm.amdgcn.class.f32(float, i32) #1
attributes #0 = { nounwind readnone speculatable willreturn }
attributes #1 = { nounwind readnone speculatable }