1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
3 # Check that we can recognize a shuffle mask for a zip instruction, and produce
4 # G_ZIP1 or G_ZIP2 where appropriate.
6 # RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-lowering -verify-machineinstrs %s -o - | FileCheck %s
13 tracksRegLiveness: true
18 ; CHECK-LABEL: name: zip1_v2s32
19 ; CHECK: liveins: $d0, $d1
20 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
21 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
22 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<2 x s32>) = G_ZIP1 [[COPY]], [[COPY1]]
23 ; CHECK: $d0 = COPY [[ZIP1_]](<2 x s32>)
24 ; CHECK: RET_ReallyLR implicit $d0
25 %0:_(<2 x s32>) = COPY $d0
26 %1:_(<2 x s32>) = COPY $d1
27 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(0, 2)
28 $d0 = COPY %2(<2 x s32>)
29 RET_ReallyLR implicit $d0
36 tracksRegLiveness: true
41 ; CHECK-LABEL: name: zip1_v2s64
42 ; CHECK: liveins: $q0, $q1
43 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
44 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
45 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<2 x s64>) = G_ZIP1 [[COPY]], [[COPY1]]
46 ; CHECK: $q0 = COPY [[ZIP1_]](<2 x s64>)
47 ; CHECK: RET_ReallyLR implicit $q0
48 %0:_(<2 x s64>) = COPY $q0
49 %1:_(<2 x s64>) = COPY $q1
50 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 2)
51 $q0 = COPY %2(<2 x s64>)
52 RET_ReallyLR implicit $q0
59 tracksRegLiveness: true
64 ; CHECK-LABEL: name: zip1_v4s32
65 ; CHECK: liveins: $q0, $q1
66 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
67 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
68 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<4 x s32>) = G_ZIP1 [[COPY]], [[COPY1]]
69 ; CHECK: $q0 = COPY [[ZIP1_]](<4 x s32>)
70 ; CHECK: RET_ReallyLR implicit $q0
71 %0:_(<4 x s32>) = COPY $q0
72 %1:_(<4 x s32>) = COPY $q1
73 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(0, 4, 1, 5)
74 $q0 = COPY %2(<4 x s32>)
75 RET_ReallyLR implicit $q0
82 tracksRegLiveness: true
87 ; CHECK-LABEL: name: zip2_v2s32
88 ; CHECK: liveins: $d0, $d1
89 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
90 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
91 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<2 x s32>) = G_ZIP2 [[COPY]], [[COPY1]]
92 ; CHECK: $d0 = COPY [[ZIP2_]](<2 x s32>)
93 ; CHECK: RET_ReallyLR implicit $d0
94 %0:_(<2 x s32>) = COPY $d0
95 %1:_(<2 x s32>) = COPY $d1
96 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(1, 3)
97 $d0 = COPY %2(<2 x s32>)
98 RET_ReallyLR implicit $d0
105 tracksRegLiveness: true
110 ; CHECK-LABEL: name: zip2_v2s64
111 ; CHECK: liveins: $q0, $q1
112 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
113 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
114 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<2 x s64>) = G_ZIP2 [[COPY]], [[COPY1]]
115 ; CHECK: $q0 = COPY [[ZIP2_]](<2 x s64>)
116 ; CHECK: RET_ReallyLR implicit $q0
117 %0:_(<2 x s64>) = COPY $q0
118 %1:_(<2 x s64>) = COPY $q1
119 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 3)
120 $q0 = COPY %2(<2 x s64>)
121 RET_ReallyLR implicit $q0
128 tracksRegLiveness: true
133 ; CHECK-LABEL: name: zip2_v4s32
134 ; CHECK: liveins: $q0, $q1
135 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
136 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
137 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<4 x s32>) = G_ZIP2 [[COPY]], [[COPY1]]
138 ; CHECK: $q0 = COPY [[ZIP2_]](<4 x s32>)
139 ; CHECK: RET_ReallyLR implicit $q0
140 %0:_(<4 x s32>) = COPY $q0
141 %1:_(<4 x s32>) = COPY $q1
142 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(2, 6, 3, 7)
143 $q0 = COPY %2(<4 x s32>)
144 RET_ReallyLR implicit $q0
148 name: zip2_no_combine_idx_mismatch
151 tracksRegLiveness: true
156 ; This will fail because it expects 3 to be the second element of the
157 ; shuffle vector mask.
159 ; CHECK-LABEL: name: zip2_no_combine_idx_mismatch
160 ; CHECK: liveins: $q0, $q1
161 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
162 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
163 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
164 ; CHECK: [[EXT:%[0-9]+]]:_(<2 x s64>) = G_EXT [[COPY]], [[COPY1]], [[C]](s32)
165 ; CHECK: $q0 = COPY [[EXT]](<2 x s64>)
166 ; CHECK: RET_ReallyLR implicit $q0
167 %0:_(<2 x s64>) = COPY $q0
168 %1:_(<2 x s64>) = COPY $q1
169 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 2)
170 $q0 = COPY %2(<2 x s64>)
171 RET_ReallyLR implicit $q0
175 name: zip1_no_combine_idx_mismatch
178 tracksRegLiveness: true
183 ; This will fail because it expects 2 to be the second element of the
184 ; shuffle vector mask.
186 ; CHECK-LABEL: name: zip1_no_combine_idx_mismatch
187 ; CHECK: liveins: $q0, $q1
188 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
189 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
190 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
191 ; CHECK: [[EXT:%[0-9]+]]:_(<2 x s64>) = G_EXT [[COPY]], [[COPY1]], [[C]](s32)
192 ; CHECK: $q0 = COPY [[EXT]](<2 x s64>)
193 ; CHECK: RET_ReallyLR implicit $q0
194 %0:_(<2 x s64>) = COPY $q0
195 %1:_(<2 x s64>) = COPY $q1
196 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 1)
197 $q0 = COPY %2(<2 x s64>)
198 RET_ReallyLR implicit $q0
202 name: no_combine_first_elt_of_mask_must_be_zero_or_one
205 tracksRegLiveness: true
210 ; zip1/zip2 must have 0 or 1 as the first element in the shuffle mask.
212 ; CHECK-LABEL: name: no_combine_first_elt_of_mask_must_be_zero_or_one
213 ; CHECK: liveins: $q0, $q1
214 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
215 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
216 ; CHECK: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(3, 4, 1, 5)
217 ; CHECK: $q0 = COPY [[SHUF]](<4 x s32>)
218 ; CHECK: RET_ReallyLR implicit $q0
219 %0:_(<4 x s32>) = COPY $q0
220 %1:_(<4 x s32>) = COPY $q1
221 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(3, 4, 1, 5)
222 $q0 = COPY %2(<4 x s32>)
223 RET_ReallyLR implicit $q0