1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -o - -mtriple=aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s
4 name: extract_from_build_vector
6 tracksRegLiveness: true
13 machineFunctionInfo: {}
18 ; CHECK-LABEL: name: extract_from_build_vector
19 ; CHECK: liveins: $x0, $x1
21 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0
22 ; CHECK-NEXT: $x0 = COPY %arg1(s64)
23 ; CHECK-NEXT: RET_ReallyLR implicit $x0
24 %arg1:_(s64) = COPY $x0
25 %arg2:_(s64) = COPY $x1
26 %zero:_(s32) = G_CONSTANT i32 0
27 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
28 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %zero(s32)
29 $x0 = COPY %extract(s64)
30 RET_ReallyLR implicit $x0
34 name: extract_from_trunc_build_vector
36 tracksRegLiveness: true
43 machineFunctionInfo: {}
48 ; CHECK-LABEL: name: extract_from_trunc_build_vector
49 ; CHECK: liveins: $x0, $x1
51 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0
52 ; CHECK-NEXT: %extract:_(s32) = G_TRUNC %arg1(s64)
53 ; CHECK-NEXT: %zext:_(s64) = G_ZEXT %extract(s32)
54 ; CHECK-NEXT: $x0 = COPY %zext(s64)
55 ; CHECK-NEXT: RET_ReallyLR implicit $x0
56 %arg1:_(s64) = COPY $x0
57 %arg2:_(s64) = COPY $x1
58 %zero:_(s32) = G_CONSTANT i32 0
59 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
60 %truncbv:_(<2 x s32>) = G_TRUNC %bv
61 %extract:_(s32) = G_EXTRACT_VECTOR_ELT %truncbv(<2 x s32>), %zero(s32)
62 %zext:_(s64) = G_ZEXT %extract
64 RET_ReallyLR implicit $x0
68 name: extract_from_build_vector_idx1
70 tracksRegLiveness: true
77 machineFunctionInfo: {}
82 ; CHECK-LABEL: name: extract_from_build_vector_idx1
83 ; CHECK: liveins: $x0, $x1
85 ; CHECK-NEXT: %arg2:_(s64) = COPY $x1
86 ; CHECK-NEXT: $x0 = COPY %arg2(s64)
87 ; CHECK-NEXT: RET_ReallyLR implicit $x0
88 %arg1:_(s64) = COPY $x0
89 %arg2:_(s64) = COPY $x1
90 %one:_(s32) = G_CONSTANT i32 1
91 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
92 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %one(s32)
93 $x0 = COPY %extract(s64)
94 RET_ReallyLR implicit $x0
98 name: extract_from_build_vector_idx_invalid
100 tracksRegLiveness: true
107 machineFunctionInfo: {}
112 ; CHECK-LABEL: name: extract_from_build_vector_idx_invalid
113 ; CHECK: liveins: $x0, $x1
115 ; CHECK-NEXT: %extract:_(s64) = G_IMPLICIT_DEF
116 ; CHECK-NEXT: $x0 = COPY %extract(s64)
117 ; CHECK-NEXT: RET_ReallyLR implicit $x0
118 %arg1:_(s64) = COPY $x0
119 %arg2:_(s64) = COPY $x1
120 %idx:_(s32) = G_CONSTANT i32 4
121 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
122 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %idx(s32)
123 $x0 = COPY %extract(s64)
124 RET_ReallyLR implicit $x0
128 name: extract_from_build_vector_trunc
130 tracksRegLiveness: true
137 machineFunctionInfo: {}
142 ; CHECK-LABEL: name: extract_from_build_vector_trunc
143 ; CHECK: liveins: $x0, $x1
145 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0
146 ; CHECK-NEXT: %extract:_(s32) = G_TRUNC %arg1(s64)
147 ; CHECK-NEXT: $w0 = COPY %extract(s32)
148 ; CHECK-NEXT: RET_ReallyLR implicit $w0
149 %arg1:_(s64) = COPY $x0
150 %arg2:_(s64) = COPY $x1
151 %zero:_(s32) = G_CONSTANT i32 0
152 %bv:_(<2 x s32>) = G_BUILD_VECTOR_TRUNC %arg1(s64), %arg2(s64)
153 %extract:_(s32) = G_EXTRACT_VECTOR_ELT %bv(<2 x s32>), %zero(s32)
154 $w0 = COPY %extract(s32)
155 RET_ReallyLR implicit $w0
159 name: extract_from_build_vector_multiple_uses
161 tracksRegLiveness: true
168 machineFunctionInfo: {}
173 ; CHECK-LABEL: name: extract_from_build_vector_multiple_uses
174 ; CHECK: liveins: $x0, $x1
176 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0
177 ; CHECK-NEXT: %arg2:_(s64) = COPY $x1
178 ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
179 ; CHECK-NEXT: %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
180 ; CHECK-NEXT: %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %zero(s32)
181 ; CHECK-NEXT: $x0 = COPY %extract(s64)
182 ; CHECK-NEXT: $q0 = COPY %bv(<2 x s64>)
183 ; CHECK-NEXT: RET_ReallyLR implicit $x0
184 %arg1:_(s64) = COPY $x0
185 %arg2:_(s64) = COPY $x1
186 %zero:_(s32) = G_CONSTANT i32 0
187 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
188 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %zero(s32)
189 $x0 = COPY %extract(s64)
190 $q0 = COPY %bv(<2 x s64>)
191 RET_ReallyLR implicit $x0
195 name: extract_from_insert
197 tracksRegLiveness: true
206 ; This test checks that this combine runs after the insertvec->build_vector
208 ; CHECK-LABEL: name: extract_from_insert
209 ; CHECK: liveins: $x0, $x1
211 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0
212 ; CHECK-NEXT: $x0 = COPY %arg1(s64)
213 ; CHECK-NEXT: RET_ReallyLR implicit $x0
214 %arg1:_(s64) = COPY $x0
215 %arg2:_(s64) = COPY $x1
216 %undef:_(<2 x s64>) = G_IMPLICIT_DEF
217 %zero:_(s32) = G_CONSTANT i32 0
218 %one:_(s32) = G_CONSTANT i32 1
219 %ins1:_(<2 x s64>) = G_INSERT_VECTOR_ELT %undef, %arg1(s64), %zero(s32)
220 %ins2:_(<2 x s64>) = G_INSERT_VECTOR_ELT %ins1, %arg2(s64), %one(s32)
221 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %ins2(<2 x s64>), %zero(s32)
222 $x0 = COPY %extract(s64)
223 RET_ReallyLR implicit $x0
227 name: extract_from_idx_negative
237 ; CHECK-LABEL: name: extract_from_idx_negative
238 ; CHECK: liveins: $x0, $x1
240 ; CHECK-NEXT: %extract:_(s64) = G_IMPLICIT_DEF
241 ; CHECK-NEXT: $x0 = COPY %extract(s64)
242 ; CHECK-NEXT: RET_ReallyLR implicit $x0
243 %vec:_(<2 x s64>) = COPY $q0
244 %idx:_(s32) = G_CONSTANT i32 -2
245 %extract:_(s64) = G_EXTRACT_VECTOR_ELT %vec(<2 x s64>), %idx(s32)
246 $x0 = COPY %extract(s64)
247 RET_ReallyLR implicit $x0