xref: /llvm-project/llvm/test/CodeGen/AMDGPU/twoaddr-mad.mir (revision 69657eb7f67600ec1c5c449d13eef3670dfb64da)
1# RUN: llc -mtriple=amdgcn -mcpu=gfx900 %s -run-pass twoaddressinstruction -verify-machineinstrs -o - | FileCheck -check-prefix=GCN %s
2# RUN: llc -mtriple=amdgcn -mcpu=gfx900 %s --passes=two-address-instruction -verify-each -o - | FileCheck -check-prefix=GCN %s
3
4# GCN-LABEL: name: test_madmk_reg_imm_f32
5# GCN: V_MADMK_F32 killed %0.sub0, 1078523331, killed %1, implicit $mode, implicit $exec
6---
7name:            test_madmk_reg_imm_f32
8registers:
9  - { id: 0, class: vreg_64 }
10  - { id: 1, class: vgpr_32 }
11  - { id: 2, class: vgpr_32 }
12  - { id: 3, class: vgpr_32 }
13body:             |
14  bb.0:
15
16    %0 = IMPLICIT_DEF
17    %1 = COPY %0.sub1
18    %2 = V_MOV_B32_e32 1078523331, implicit $exec
19    %3 = V_MAC_F32_e32 killed %0.sub0, %2, killed %1, implicit $mode, implicit $exec
20
21...
22
23# GCN-LABEL: name: test_madmk_imm_reg_f32
24# GCN: V_MADMK_F32 killed %0.sub0, 1078523331, killed %1, implicit $mode, implicit $exec
25---
26name:            test_madmk_imm_reg_f32
27registers:
28  - { id: 0, class: vreg_64 }
29  - { id: 1, class: vgpr_32 }
30  - { id: 2, class: vgpr_32 }
31  - { id: 3, class: vgpr_32 }
32body:             |
33  bb.0:
34
35    %0 = IMPLICIT_DEF
36    %1 = COPY %0.sub1
37    %2 = V_MOV_B32_e32 1078523331, implicit $exec
38    %3 = V_MAC_F32_e32 %2, killed %0.sub0, killed %1, implicit $mode, implicit $exec
39
40...
41
42# GCN-LABEL: name: test_madak_f32
43# GCN: V_MADAK_F32 killed %0.sub0, %0.sub1, 1078523331, implicit $mode, implicit $exec
44---
45name:            test_madak_f32
46registers:
47  - { id: 0, class: vreg_64 }
48  - { id: 1, class: vgpr_32 }
49  - { id: 2, class: vgpr_32 }
50body:             |
51  bb.0:
52
53    %0 = IMPLICIT_DEF
54    %1 = V_MOV_B32_e32 1078523331, implicit $exec
55    %2 = V_MAC_F32_e32 killed %0.sub0, %0.sub1, %1, implicit $mode, implicit $exec
56    S_ENDPGM 0, implicit %1
57...
58
59# GCN-LABEL: name: test_madmk_reg_imm_f16
60# GCN: V_MADMK_F16 killed %0.sub0, 1078523331, killed %1, implicit $mode, implicit $exec
61---
62name:            test_madmk_reg_imm_f16
63registers:
64  - { id: 0, class: vreg_64 }
65  - { id: 1, class: vgpr_32 }
66  - { id: 2, class: vgpr_32 }
67  - { id: 3, class: vgpr_32 }
68body:             |
69  bb.0:
70
71    %0 = IMPLICIT_DEF
72    %1 = COPY %0.sub1
73    %2 = V_MOV_B32_e32 1078523331, implicit $exec
74    %3 = V_MAC_F16_e32 killed %0.sub0, %2, killed %1, implicit $mode, implicit $exec
75
76...
77
78# GCN-LABEL: name: test_madmk_imm_reg_f16
79# GCN: V_MADMK_F16 killed %0.sub0, 1078523331, killed %1, implicit $mode, implicit $exec
80---
81name:            test_madmk_imm_reg_f16
82registers:
83  - { id: 0, class: vreg_64 }
84  - { id: 1, class: vgpr_32 }
85  - { id: 2, class: vgpr_32 }
86  - { id: 3, class: vgpr_32 }
87body:             |
88  bb.0:
89
90    %0 = IMPLICIT_DEF
91    %1 = COPY %0.sub1
92    %2 = V_MOV_B32_e32 1078523331, implicit $exec
93    %3 = V_MAC_F16_e32 %2, killed %0.sub0, killed %1, implicit $mode, implicit $exec
94
95...
96
97# GCN-LABEL: name: test_madak_f16
98# GCN: V_MADAK_F16 killed %0.sub0, %0.sub1, 1078523331, implicit $mode, implicit $exec
99---
100name:            test_madak_f16
101registers:
102  - { id: 0, class: vreg_64 }
103  - { id: 1, class: vgpr_32 }
104  - { id: 2, class: vgpr_32 }
105body:             |
106  bb.0:
107
108    %0 = IMPLICIT_DEF
109    %1 = V_MOV_B32_e32 1078523331, implicit $exec
110    %2 = V_MAC_F16_e32 killed %0.sub0, %0.sub1, %1, implicit $mode, implicit $exec
111    S_ENDPGM 0, implicit %1
112...
113
114# Make sure constant bus restriction isn't violated if src0 is an SGPR.
115
116# GCN-LABEL: name: test_madak_sgpr_src0_f32
117# GCN: %1:vgpr_32 = V_MOV_B32_e32 1078523331, implicit $exec
118# GCN: %3:vgpr_32 = V_MAD_F32_e64 0, killed %0, 0, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
119
120---
121name:            test_madak_sgpr_src0_f32
122registers:
123  - { id: 0, class: sreg_32_xm0 }
124  - { id: 1, class: vgpr_32}
125  - { id: 2, class: vgpr_32 }
126  - { id: 3, class: vgpr_32 }
127body:             |
128  bb.0:
129
130    %0 = IMPLICIT_DEF
131    %1 = V_MOV_B32_e32 1078523331, implicit $exec
132    %2 = IMPLICIT_DEF
133    %3 = V_MAC_F32_e32 killed %0, %1, %2, implicit $mode, implicit $exec
134    S_ENDPGM 0, implicit %2
135...
136
137# This can still fold if this is an inline immediate.
138
139# GCN-LABEL: name: test_madak_inlineimm_src0_f32
140# GCN: %2:vgpr_32 = V_MADMK_F32 1073741824, 1078523331, %1, implicit $mode, implicit $exec
141
142---
143name:            test_madak_inlineimm_src0_f32
144registers:
145  - { id: 0, class: vgpr_32}
146  - { id: 1, class: vgpr_32 }
147  - { id: 2, class: vgpr_32 }
148body:             |
149  bb.0:
150
151    %0 = V_MOV_B32_e32 1078523331, implicit $exec
152    %1 = IMPLICIT_DEF
153    %2 = V_MAC_F32_e32 1073741824, %0, %1, implicit $mode, implicit $exec
154    S_ENDPGM 0, implicit %1
155...
156# Non-inline immediate uses constant bus already.
157
158# GCN-LABEL: name: test_madak_otherimm_src0_f32
159# GCN: %2:vgpr_32 = V_MADMK_F32 %0, 1120403456, %1, implicit $mode, implicit $exec
160
161---
162name:            test_madak_otherimm_src0_f32
163registers:
164  - { id: 0, class: vgpr_32}
165  - { id: 1, class: vgpr_32 }
166  - { id: 2, class: vgpr_32 }
167body:             |
168  bb.0:
169
170    %0 = V_MOV_B32_e32 1078523331, implicit $exec
171    %1 = IMPLICIT_DEF
172    %2 = V_MAC_F32_e32 1120403456, %0, %1, implicit $mode, implicit $exec
173    S_ENDPGM 0, implicit %1
174...
175# Non-inline immediate uses constant bus already.
176
177# GCN-LABEL: name: test_madak_other_constantlike_src0_f32
178# GCN: %2:vgpr_32 = V_MAC_F32_e32 %stack.0, %0, %2, implicit $mode, implicit $exec
179---
180name:            test_madak_other_constantlike_src0_f32
181registers:
182  - { id: 0, class: vgpr_32}
183  - { id: 1, class: vgpr_32 }
184  - { id: 2, class: vgpr_32 }
185stack:
186  - { id: 0, name: "", type: default, offset: 0, size: 128, alignment: 8,
187      callee-saved-register: '', local-offset: 0, debug-info-variable: '',
188      debug-info-expression: '', debug-info-location: '' }
189body:             |
190  bb.0:
191
192    %0 = V_MOV_B32_e32 1078523331, implicit $exec
193    %1 = IMPLICIT_DEF
194    %2 = V_MAC_F32_e32 %stack.0, %0, %1, implicit $mode, implicit $exec
195
196...
197
198# GCN-LABEL: name: test_madak_inline_literal_f16
199# GCN: %2:vgpr_32 = V_MADAK_F16 16384, killed %0, 49664, implicit $mode, implicit $exec
200
201---
202name:            test_madak_inline_literal_f16
203body:             |
204  bb.0:
205    %3:vgpr_32 = COPY killed $vgpr0
206
207    %26:vgpr_32 = V_MOV_B32_e32 49664, implicit $exec
208    %28:vgpr_32 = V_MAC_F16_e32 16384, killed %3, %26, implicit $mode, implicit $exec
209    S_ENDPGM 0, implicit %26
210...
211
212# GCN-LABEL: name: test_mad_src0mods
213# GCN: %3:vgpr_32 = V_MAD_F32_e64 1, %0, 0, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
214---
215name: test_mad_src0mods
216body: |
217  bb.0:
218    %0:vgpr_32 = IMPLICIT_DEF
219    %1:vgpr_32 = IMPLICIT_DEF
220    %2:vgpr_32 = IMPLICIT_DEF
221    %3:vgpr_32 = V_MAC_F32_e64 1, %0, 0, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
222    S_ENDPGM 0, implicit %2
223...
224
225# GCN-LABEL: name: test_mad_src1mods
226# GCN: %3:vgpr_32 = V_MAD_F32_e64 0, %0, 1, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
227---
228name: test_mad_src1mods
229body: |
230  bb.0:
231    %0:vgpr_32 = IMPLICIT_DEF
232    %1:vgpr_32 = IMPLICIT_DEF
233    %2:vgpr_32 = IMPLICIT_DEF
234    %3:vgpr_32 = V_MAC_F32_e64 0, %0, 1, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
235    S_ENDPGM 0, implicit %2
236...
237
238# GCN-LABEL: name: test_mad_src2mods
239# GCN: %3:vgpr_32 = V_MAD_F32_e64 0, %0, 0, %1, 1, %2, 0, 0, implicit $mode, implicit $exec
240---
241name: test_mad_src2mods
242body: |
243  bb.0:
244    %0:vgpr_32 = IMPLICIT_DEF
245    %1:vgpr_32 = IMPLICIT_DEF
246    %2:vgpr_32 = IMPLICIT_DEF
247    %3:vgpr_32 = V_MAC_F32_e64 0, %0, 0, %1, 1, %2, 0, 0, implicit $mode, implicit $exec
248    S_ENDPGM 0, implicit %2
249...
250