xref: /llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-pattern-xor3.mir (revision 9e9907f1cfa424366fba58d9520f9305b537cec9)
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=amdgcn -mcpu=fiji -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX8 %s
3# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX9 %s
4# RUN: llc -mtriple=amdgcn -mcpu=gfx1010 -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX10 %s
5# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -run-pass=instruction-select -verify-machineinstrs -o - %s  | FileCheck -check-prefix=GFX10 %s
6
7---
8
9name:            xor_s32_sgpr_sgpr_sgpr
10legalized:       true
11regBankSelected: true
12tracksRegLiveness: true
13
14body: |
15  bb.0:
16    liveins: $sgpr0, $sgpr1, $sgpr2
17    ; GFX8-LABEL: name: xor_s32_sgpr_sgpr_sgpr
18    ; GFX8: liveins: $sgpr0, $sgpr1, $sgpr2
19    ; GFX8-NEXT: {{  $}}
20    ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
21    ; GFX8-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
22    ; GFX8-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
23    ; GFX8-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
24    ; GFX8-NEXT: [[S_XOR_B32_1:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_XOR_B32_]], [[COPY2]], implicit-def dead $scc
25    ; GFX8-NEXT: S_ENDPGM 0, implicit [[S_XOR_B32_1]]
26    ;
27    ; GFX9-LABEL: name: xor_s32_sgpr_sgpr_sgpr
28    ; GFX9: liveins: $sgpr0, $sgpr1, $sgpr2
29    ; GFX9-NEXT: {{  $}}
30    ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
31    ; GFX9-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
32    ; GFX9-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
33    ; GFX9-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
34    ; GFX9-NEXT: [[S_XOR_B32_1:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_XOR_B32_]], [[COPY2]], implicit-def dead $scc
35    ; GFX9-NEXT: S_ENDPGM 0, implicit [[S_XOR_B32_1]]
36    ;
37    ; GFX10-LABEL: name: xor_s32_sgpr_sgpr_sgpr
38    ; GFX10: liveins: $sgpr0, $sgpr1, $sgpr2
39    ; GFX10-NEXT: {{  $}}
40    ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
41    ; GFX10-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
42    ; GFX10-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr2
43    ; GFX10-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
44    ; GFX10-NEXT: [[S_XOR_B32_1:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_XOR_B32_]], [[COPY2]], implicit-def dead $scc
45    ; GFX10-NEXT: S_ENDPGM 0, implicit [[S_XOR_B32_1]]
46    %0:sgpr(s32) = COPY $sgpr0
47    %1:sgpr(s32) = COPY $sgpr1
48    %2:sgpr(s32) = COPY $sgpr2
49    %3:sgpr(s32) = G_XOR %0, %1
50    %4:sgpr(s32) = G_XOR %3, %2
51    S_ENDPGM 0, implicit %4
52...
53
54---
55
56name:            xor_s32_vgpr_vgpr_vgpr
57legalized:       true
58regBankSelected: true
59tracksRegLiveness: true
60
61body: |
62  bb.0:
63    liveins: $vgpr0, $vgpr1, $vgpr2
64    ; GFX8-LABEL: name: xor_s32_vgpr_vgpr_vgpr
65    ; GFX8: liveins: $vgpr0, $vgpr1, $vgpr2
66    ; GFX8-NEXT: {{  $}}
67    ; GFX8-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
68    ; GFX8-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
69    ; GFX8-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
70    ; GFX8-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY]], [[COPY1]], implicit $exec
71    ; GFX8-NEXT: [[V_XOR_B32_e64_1:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[V_XOR_B32_e64_]], [[COPY2]], implicit $exec
72    ; GFX8-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_1]]
73    ;
74    ; GFX9-LABEL: name: xor_s32_vgpr_vgpr_vgpr
75    ; GFX9: liveins: $vgpr0, $vgpr1, $vgpr2
76    ; GFX9-NEXT: {{  $}}
77    ; GFX9-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
78    ; GFX9-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
79    ; GFX9-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
80    ; GFX9-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY]], [[COPY1]], implicit $exec
81    ; GFX9-NEXT: [[V_XOR_B32_e64_1:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[V_XOR_B32_e64_]], [[COPY2]], implicit $exec
82    ; GFX9-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_1]]
83    ;
84    ; GFX10-LABEL: name: xor_s32_vgpr_vgpr_vgpr
85    ; GFX10: liveins: $vgpr0, $vgpr1, $vgpr2
86    ; GFX10-NEXT: {{  $}}
87    ; GFX10-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
88    ; GFX10-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
89    ; GFX10-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
90    ; GFX10-NEXT: [[V_XOR3_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR3_B32_e64 [[COPY]], [[COPY1]], [[COPY2]], implicit $exec
91    ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_XOR3_B32_e64_]]
92    %0:vgpr(s32) = COPY $vgpr0
93    %1:vgpr(s32) = COPY $vgpr1
94    %2:vgpr(s32) = COPY $vgpr2
95    %3:vgpr(s32) = G_XOR %0, %1
96    %4:vgpr(s32) = G_XOR %3, %2
97    S_ENDPGM 0, implicit %4
98...
99
100# Mixed SGPR and VGPR, with full copy from scalar xor to VGPR, as
101#should actually be produced by RegBankSelect
102
103---
104
105name:            xor_s32_sgpr_sgpr_vgpr_copy
106legalized:       true
107regBankSelected: true
108tracksRegLiveness: true
109
110body: |
111  bb.0:
112    liveins: $sgpr0, $sgpr1, $vgpr0
113
114    ; GFX8-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy
115    ; GFX8: liveins: $sgpr0, $sgpr1, $vgpr0
116    ; GFX8-NEXT: {{  $}}
117    ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
118    ; GFX8-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
119    ; GFX8-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
120    ; GFX8-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
121    ; GFX8-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
122    ; GFX8-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY3]], [[COPY2]], implicit $exec
123    ; GFX8-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
124    ;
125    ; GFX9-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy
126    ; GFX9: liveins: $sgpr0, $sgpr1, $vgpr0
127    ; GFX9-NEXT: {{  $}}
128    ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
129    ; GFX9-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
130    ; GFX9-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
131    ; GFX9-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
132    ; GFX9-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
133    ; GFX9-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY3]], [[COPY2]], implicit $exec
134    ; GFX9-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
135    ;
136    ; GFX10-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy
137    ; GFX10: liveins: $sgpr0, $sgpr1, $vgpr0
138    ; GFX10-NEXT: {{  $}}
139    ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
140    ; GFX10-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
141    ; GFX10-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
142    ; GFX10-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
143    ; GFX10-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
144    ; GFX10-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY3]], [[COPY2]], implicit $exec
145    ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
146    %0:sgpr(s32) = COPY $sgpr0
147    %1:sgpr(s32) = COPY $sgpr1
148    %2:vgpr(s32) = COPY $vgpr0
149    %3:sgpr(s32) = G_XOR %0, %1
150    %4:vgpr(s32) = COPY %3
151    %5:vgpr(s32) = G_XOR %4, %2
152    S_ENDPGM 0, implicit %5
153...
154
155---
156
157name:            xor_s32_sgpr_sgpr_vgpr_copy_commute
158legalized:       true
159regBankSelected: true
160tracksRegLiveness: true
161
162body: |
163  bb.0:
164    liveins: $sgpr0, $sgpr1, $vgpr0
165
166    ; GFX8-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy_commute
167    ; GFX8: liveins: $sgpr0, $sgpr1, $vgpr0
168    ; GFX8-NEXT: {{  $}}
169    ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
170    ; GFX8-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
171    ; GFX8-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
172    ; GFX8-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
173    ; GFX8-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
174    ; GFX8-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY2]], [[COPY3]], implicit $exec
175    ; GFX8-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
176    ;
177    ; GFX9-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy_commute
178    ; GFX9: liveins: $sgpr0, $sgpr1, $vgpr0
179    ; GFX9-NEXT: {{  $}}
180    ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
181    ; GFX9-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
182    ; GFX9-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
183    ; GFX9-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
184    ; GFX9-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
185    ; GFX9-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY2]], [[COPY3]], implicit $exec
186    ; GFX9-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
187    ;
188    ; GFX10-LABEL: name: xor_s32_sgpr_sgpr_vgpr_copy_commute
189    ; GFX10: liveins: $sgpr0, $sgpr1, $vgpr0
190    ; GFX10-NEXT: {{  $}}
191    ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
192    ; GFX10-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
193    ; GFX10-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
194    ; GFX10-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
195    ; GFX10-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[S_XOR_B32_]]
196    ; GFX10-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[COPY2]], [[COPY3]], implicit $exec
197    ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
198    %0:sgpr(s32) = COPY $sgpr0
199    %1:sgpr(s32) = COPY $sgpr1
200    %2:vgpr(s32) = COPY $vgpr0
201    %3:sgpr(s32) = G_XOR %0, %1
202    %4:vgpr(s32) = COPY %3
203    %5:vgpr(s32) = G_XOR %2, %4
204    S_ENDPGM 0, implicit %5
205...
206
207---
208
209name:            xor_s32_sgpr_sgpr_vgpr
210legalized:       true
211regBankSelected: true
212tracksRegLiveness: true
213
214body: |
215  bb.0:
216    liveins: $sgpr0, $sgpr1, $vgpr0
217
218    ; GFX8-LABEL: name: xor_s32_sgpr_sgpr_vgpr
219    ; GFX8: liveins: $sgpr0, $sgpr1, $vgpr0
220    ; GFX8-NEXT: {{  $}}
221    ; GFX8-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
222    ; GFX8-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
223    ; GFX8-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
224    ; GFX8-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
225    ; GFX8-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[S_XOR_B32_]], [[COPY2]], implicit $exec
226    ; GFX8-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
227    ;
228    ; GFX9-LABEL: name: xor_s32_sgpr_sgpr_vgpr
229    ; GFX9: liveins: $sgpr0, $sgpr1, $vgpr0
230    ; GFX9-NEXT: {{  $}}
231    ; GFX9-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
232    ; GFX9-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
233    ; GFX9-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
234    ; GFX9-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[COPY]], [[COPY1]], implicit-def dead $scc
235    ; GFX9-NEXT: [[V_XOR_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR_B32_e64 [[S_XOR_B32_]], [[COPY2]], implicit $exec
236    ; GFX9-NEXT: S_ENDPGM 0, implicit [[V_XOR_B32_e64_]]
237    ;
238    ; GFX10-LABEL: name: xor_s32_sgpr_sgpr_vgpr
239    ; GFX10: liveins: $sgpr0, $sgpr1, $vgpr0
240    ; GFX10-NEXT: {{  $}}
241    ; GFX10-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
242    ; GFX10-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr1
243    ; GFX10-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr0
244    ; GFX10-NEXT: [[V_XOR3_B32_e64_:%[0-9]+]]:vgpr_32 = V_XOR3_B32_e64 [[COPY]], [[COPY1]], [[COPY2]], implicit $exec
245    ; GFX10-NEXT: S_ENDPGM 0, implicit [[V_XOR3_B32_e64_]]
246    %0:sgpr(s32) = COPY $sgpr0
247    %1:sgpr(s32) = COPY $sgpr1
248    %2:vgpr(s32) = COPY $vgpr0
249    %3:sgpr(s32) = G_XOR %0, %1
250    %4:vgpr(s32) = G_XOR %3, %2
251    S_ENDPGM 0, implicit %4
252...
253