1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -O0 -run-pass=legalizer -o - %s | FileCheck -check-prefix=GFX6 %s
3 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -O0 -run-pass=legalizer -o - %s | FileCheck -check-prefix=GFX8 %s
4 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -O0 -run-pass=legalizer -o - %s | FileCheck -check-prefix=GFX9 %s
10 liveins: $vgpr0, $vgpr1
12 ; GFX6-LABEL: name: test_add_s32
13 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
14 ; GFX6: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
15 ; GFX6: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY1]]
16 ; GFX6: $vgpr0 = COPY [[ADD]](s32)
17 ; GFX8-LABEL: name: test_add_s32
18 ; GFX8: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
19 ; GFX8: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
20 ; GFX8: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY1]]
21 ; GFX8: $vgpr0 = COPY [[ADD]](s32)
22 ; GFX9-LABEL: name: test_add_s32
23 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
24 ; GFX9: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
25 ; GFX9: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY1]]
26 ; GFX9: $vgpr0 = COPY [[ADD]](s32)
27 %0:_(s32) = COPY $vgpr0
28 %1:_(s32) = COPY $vgpr1
29 %2:_(s32) = G_ADD %0, %1
37 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
39 ; GFX6-LABEL: name: test_add_v2s32
40 ; GFX6: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
41 ; GFX6: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
42 ; GFX6: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
43 ; GFX6: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
44 ; GFX6: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[UV]], [[UV2]]
45 ; GFX6: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[UV1]], [[UV3]]
46 ; GFX6: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ADD]](s32), [[ADD1]](s32)
47 ; GFX6: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
48 ; GFX8-LABEL: name: test_add_v2s32
49 ; GFX8: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
50 ; GFX8: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
51 ; GFX8: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
52 ; GFX8: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
53 ; GFX8: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[UV]], [[UV2]]
54 ; GFX8: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[UV1]], [[UV3]]
55 ; GFX8: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ADD]](s32), [[ADD1]](s32)
56 ; GFX8: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
57 ; GFX9-LABEL: name: test_add_v2s32
58 ; GFX9: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
59 ; GFX9: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
60 ; GFX9: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
61 ; GFX9: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
62 ; GFX9: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[UV]], [[UV2]]
63 ; GFX9: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[UV1]], [[UV3]]
64 ; GFX9: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[ADD]](s32), [[ADD1]](s32)
65 ; GFX9: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
66 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
67 %1:_(<2 x s32>) = COPY $vgpr2_vgpr3
68 %2:_(<2 x s32>) = G_ADD %0, %1
69 $vgpr0_vgpr1 = COPY %2
76 liveins: $vgpr0, $vgpr1
78 ; GFX6-LABEL: name: test_add_s16
79 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
80 ; GFX6: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
81 ; GFX6: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
82 ; GFX6: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
83 ; GFX6: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]]
84 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
85 ; GFX6: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
86 ; GFX6: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
87 ; GFX6: $vgpr0 = COPY [[AND]](s32)
88 ; GFX8-LABEL: name: test_add_s16
89 ; GFX8: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
90 ; GFX8: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
91 ; GFX8: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
92 ; GFX8: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
93 ; GFX8: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC1]]
94 ; GFX8: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[ADD]](s16)
95 ; GFX8: $vgpr0 = COPY [[ZEXT]](s32)
96 ; GFX9-LABEL: name: test_add_s16
97 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
98 ; GFX9: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
99 ; GFX9: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
100 ; GFX9: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
101 ; GFX9: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC1]]
102 ; GFX9: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[ADD]](s16)
103 ; GFX9: $vgpr0 = COPY [[ZEXT]](s32)
104 %0:_(s32) = COPY $vgpr0
105 %1:_(s32) = COPY $vgpr1
106 %2:_(s16) = G_TRUNC %0
107 %3:_(s16) = G_TRUNC %1
108 %4:_(s16) = G_ADD %2, %3
109 %5:_(s32) = G_ZEXT %4
117 liveins: $vgpr0, $vgpr1
119 ; GFX6-LABEL: name: test_add_v2s16
120 ; GFX6: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
121 ; GFX6: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr1
122 ; GFX6: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
123 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
124 ; GFX6: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST]], [[C]](s32)
125 ; GFX6: [[BITCAST1:%[0-9]+]]:_(s32) = G_BITCAST [[COPY1]](<2 x s16>)
126 ; GFX6: [[LSHR1:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST1]], [[C]](s32)
127 ; GFX6: [[COPY2:%[0-9]+]]:_(s32) = COPY [[BITCAST]](s32)
128 ; GFX6: [[COPY3:%[0-9]+]]:_(s32) = COPY [[BITCAST1]](s32)
129 ; GFX6: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]]
130 ; GFX6: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
131 ; GFX6: [[COPY4:%[0-9]+]]:_(s32) = COPY [[LSHR]](s32)
132 ; GFX6: [[COPY5:%[0-9]+]]:_(s32) = COPY [[LSHR1]](s32)
133 ; GFX6: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY4]], [[COPY5]]
134 ; GFX6: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
135 ; GFX6: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[TRUNC]](s16), [[TRUNC1]](s16)
136 ; GFX6: $vgpr0 = COPY [[BUILD_VECTOR]](<2 x s16>)
137 ; GFX8-LABEL: name: test_add_v2s16
138 ; GFX8: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
139 ; GFX8: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr1
140 ; GFX8: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
141 ; GFX8: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[BITCAST]](s32)
142 ; GFX8: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
143 ; GFX8: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST]], [[C]](s32)
144 ; GFX8: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
145 ; GFX8: [[BITCAST1:%[0-9]+]]:_(s32) = G_BITCAST [[COPY1]](<2 x s16>)
146 ; GFX8: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[BITCAST1]](s32)
147 ; GFX8: [[LSHR1:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST1]], [[C]](s32)
148 ; GFX8: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR1]](s32)
149 ; GFX8: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC2]]
150 ; GFX8: [[ADD1:%[0-9]+]]:_(s16) = G_ADD [[TRUNC1]], [[TRUNC3]]
151 ; GFX8: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[ADD]](s16), [[ADD1]](s16)
152 ; GFX8: $vgpr0 = COPY [[BUILD_VECTOR]](<2 x s16>)
153 ; GFX9-LABEL: name: test_add_v2s16
154 ; GFX9: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr0
155 ; GFX9: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr1
156 ; GFX9: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
157 ; GFX9: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[BITCAST]](s32)
158 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
159 ; GFX9: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST]], [[C]](s32)
160 ; GFX9: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
161 ; GFX9: [[BITCAST1:%[0-9]+]]:_(s32) = G_BITCAST [[COPY1]](<2 x s16>)
162 ; GFX9: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[BITCAST1]](s32)
163 ; GFX9: [[LSHR1:%[0-9]+]]:_(s32) = G_LSHR [[BITCAST1]], [[C]](s32)
164 ; GFX9: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR1]](s32)
165 ; GFX9: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC2]]
166 ; GFX9: [[ADD1:%[0-9]+]]:_(s16) = G_ADD [[TRUNC1]], [[TRUNC3]]
167 ; GFX9: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[ADD]](s16), [[ADD1]](s16)
168 ; GFX9: $vgpr0 = COPY [[BUILD_VECTOR]](<2 x s16>)
169 %0:_(<2 x s16>) = COPY $vgpr0
170 %1:_(<2 x s16>) = COPY $vgpr1
171 %2:_(<2 x s16>) = G_ADD %0, %1
179 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
181 ; GFX6-LABEL: name: test_add_s64
182 ; GFX6: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
183 ; GFX6: [[COPY1:%[0-9]+]]:_(s64) = COPY $vgpr2_vgpr3
184 ; GFX6: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
185 ; GFX6: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](s64)
186 ; GFX6: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[UV]], [[UV2]]
187 ; GFX6: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[UV1]], [[UV3]], [[UADDO1]]
188 ; GFX6: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UADDO]](s32), [[UADDE]](s32)
189 ; GFX6: $vgpr0_vgpr1 = COPY [[MV]](s64)
190 ; GFX8-LABEL: name: test_add_s64
191 ; GFX8: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
192 ; GFX8: [[COPY1:%[0-9]+]]:_(s64) = COPY $vgpr2_vgpr3
193 ; GFX8: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
194 ; GFX8: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](s64)
195 ; GFX8: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[UV]], [[UV2]]
196 ; GFX8: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[UV1]], [[UV3]], [[UADDO1]]
197 ; GFX8: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UADDO]](s32), [[UADDE]](s32)
198 ; GFX8: $vgpr0_vgpr1 = COPY [[MV]](s64)
199 ; GFX9-LABEL: name: test_add_s64
200 ; GFX9: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
201 ; GFX9: [[COPY1:%[0-9]+]]:_(s64) = COPY $vgpr2_vgpr3
202 ; GFX9: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
203 ; GFX9: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](s64)
204 ; GFX9: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[UV]], [[UV2]]
205 ; GFX9: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[UV1]], [[UV3]], [[UADDO1]]
206 ; GFX9: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[UADDO]](s32), [[UADDE]](s32)
207 ; GFX9: $vgpr0_vgpr1 = COPY [[MV]](s64)
208 %0:_(s64) = COPY $vgpr0_vgpr1
209 %1:_(s64) = COPY $vgpr2_vgpr3
210 %2:_(s64) = G_ADD %0, %1
211 $vgpr0_vgpr1 = COPY %2
218 liveins: $vgpr0, $vgpr1
220 ; GFX6-LABEL: name: test_add_s7
221 ; GFX6: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
222 ; GFX6: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
223 ; GFX6: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
224 ; GFX6: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
225 ; GFX6: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[COPY3]]
226 ; GFX6: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
227 ; GFX6: [[COPY4:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
228 ; GFX6: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C]]
229 ; GFX6: $vgpr0 = COPY [[AND]](s32)
230 ; GFX8-LABEL: name: test_add_s7
231 ; GFX8: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
232 ; GFX8: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
233 ; GFX8: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
234 ; GFX8: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
235 ; GFX8: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC1]]
236 ; GFX8: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
237 ; GFX8: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ADD]](s16)
238 ; GFX8: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
239 ; GFX8: $vgpr0 = COPY [[AND]](s32)
240 ; GFX9-LABEL: name: test_add_s7
241 ; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
242 ; GFX9: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
243 ; GFX9: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
244 ; GFX9: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
245 ; GFX9: [[ADD:%[0-9]+]]:_(s16) = G_ADD [[TRUNC]], [[TRUNC1]]
246 ; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 127
247 ; GFX9: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ADD]](s16)
248 ; GFX9: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
249 ; GFX9: $vgpr0 = COPY [[AND]](s32)
250 %0:_(s32) = COPY $vgpr0
251 %1:_(s32) = COPY $vgpr1
252 %2:_(s7) = G_TRUNC %0
253 %3:_(s7) = G_TRUNC %1
254 %4:_(s7) = G_ADD %2, %3
255 %5:_(s32) = G_ZEXT %4