1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -asm-verbose=false | FileCheck %s
2 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -asm-verbose=false -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* 2>&1 | FileCheck %s --check-prefixes=CHECK,FALLBACK
4 ; Test efficient codegen of vector extends up from legal type to 128 bit
5 ; and 256 bit vector types.
11 ; FALLBACK-NOT: remark:{{.*}}(in function: func1)
12 define <8 x i16> @func1(<8 x i8> %v0) nounwind {
14 ; CHECK-NEXT: ushll.8h v0, v0, #0
16 %r = zext <8 x i8> %v0 to <8 x i16>
20 ; FALLBACK-NOT: remark:{{.*}}(in function: func2)
21 define <8 x i16> @func2(<8 x i8> %v0) nounwind {
23 ; CHECK-NEXT: sshll.8h v0, v0, #0
25 %r = sext <8 x i8> %v0 to <8 x i16>
29 define <16 x i16> @func3(<16 x i8> %v0) nounwind {
31 ; CHECK-NEXT: ushll2.8h v1, v0, #0
32 ; CHECK-NEXT: ushll.8h v0, v0, #0
34 %r = zext <16 x i8> %v0 to <16 x i16>
38 define <16 x i16> @func4(<16 x i8> %v0) nounwind {
40 ; CHECK-NEXT: sshll2.8h v1, v0, #0
41 ; CHECK-NEXT: sshll.8h v0, v0, #0
43 %r = sext <16 x i8> %v0 to <16 x i16>
51 ; FALLBACK-NOT: remark:{{.*}}(in function: afunc1)
52 define <4 x i32> @afunc1(<4 x i16> %v0) nounwind {
53 ; CHECK-LABEL: afunc1:
54 ; CHECK-NEXT: ushll.4s v0, v0, #0
56 %r = zext <4 x i16> %v0 to <4 x i32>
60 ; FALLBACK-NOT: remark:{{.*}}(in function: afunc2)
61 define <4 x i32> @afunc2(<4 x i16> %v0) nounwind {
62 ; CHECK-LABEL: afunc2:
63 ; CHECK-NEXT: sshll.4s v0, v0, #0
65 %r = sext <4 x i16> %v0 to <4 x i32>
69 define <8 x i32> @afunc3(<8 x i16> %v0) nounwind {
70 ; CHECK-LABEL: afunc3:
71 ; CHECK-NEXT: ushll2.4s v1, v0, #0
72 ; CHECK-NEXT: ushll.4s v0, v0, #0
74 %r = zext <8 x i16> %v0 to <8 x i32>
78 define <8 x i32> @afunc4(<8 x i16> %v0) nounwind {
79 ; CHECK-LABEL: afunc4:
80 ; CHECK-NEXT: sshll2.4s v1, v0, #0
81 ; CHECK-NEXT: sshll.4s v0, v0, #0
83 %r = sext <8 x i16> %v0 to <8 x i32>
87 define <8 x i32> @bfunc1(<8 x i8> %v0) nounwind {
88 ; CHECK-LABEL: bfunc1:
89 ; CHECK-NEXT: ushll.8h v0, v0, #0
90 ; CHECK-NEXT: ushll2.4s v1, v0, #0
91 ; CHECK-NEXT: ushll.4s v0, v0, #0
93 %r = zext <8 x i8> %v0 to <8 x i32>
97 define <8 x i32> @bfunc2(<8 x i8> %v0) nounwind {
98 ; CHECK-LABEL: bfunc2:
99 ; CHECK-NEXT: sshll.8h v0, v0, #0
100 ; CHECK-NEXT: sshll2.4s v1, v0, #0
101 ; CHECK-NEXT: sshll.4s v0, v0, #0
103 %r = sext <8 x i8> %v0 to <8 x i32>
111 define <4 x i64> @zfunc1(<4 x i32> %v0) nounwind {
112 ; CHECK-LABEL: zfunc1:
113 ; CHECK-NEXT: ushll2.2d v1, v0, #0
114 ; CHECK-NEXT: ushll.2d v0, v0, #0
116 %r = zext <4 x i32> %v0 to <4 x i64>
120 define <4 x i64> @zfunc2(<4 x i32> %v0) nounwind {
121 ; CHECK-LABEL: zfunc2:
122 ; CHECK-NEXT: sshll2.2d v1, v0, #0
123 ; CHECK-NEXT: sshll.2d v0, v0, #0
125 %r = sext <4 x i32> %v0 to <4 x i64>
129 define <4 x i64> @bfunc3(<4 x i16> %v0) nounwind {
130 ; CHECK-LABEL: func3:
131 ; CHECK-NEXT: ushll.4s v0, v0, #0
132 ; CHECK-NEXT: ushll2.2d v1, v0, #0
133 ; CHECK-NEXT: ushll.2d v0, v0, #0
135 %r = zext <4 x i16> %v0 to <4 x i64>
139 define <4 x i64> @cfunc4(<4 x i16> %v0) nounwind {
140 ; CHECK-LABEL: func4:
141 ; CHECK-NEXT: sshll.4s v0, v0, #0
142 ; CHECK-NEXT: sshll2.2d v1, v0, #0
143 ; CHECK-NEXT: sshll.2d v0, v0, #0
145 %r = sext <4 x i16> %v0 to <4 x i64>
149 define <4 x i64> @zext_v4i8_to_v4i64(<4 x i8> %v0) nounwind {
150 ; CHECK-LABEL: zext_v4i8_to_v4i64:
151 ; CHECK-NEXT: bic.4h v0, #255, lsl #8
152 ; CHECK-NEXT: ushll.4s v0, v0, #0
153 ; CHECK-NEXT: ushll2.2d v1, v0, #0
154 ; CHECK-NEXT: ushll.2d v0, v0, #0
157 %r = zext <4 x i8> %v0 to <4 x i64>
161 define <4 x i64> @sext_v4i8_to_v4i64(<4 x i8> %v0) nounwind {
162 ; CHECK-LABEL: sext_v4i8_to_v4i64:
163 ; CHECK-NEXT: ushll.4s v0, v0, #0
164 ; CHECK-NEXT: ushll.2d v1, v0, #0
165 ; CHECK-NEXT: ushll2.2d v0, v0, #0
166 ; CHECK-NEXT: shl.2d v0, v0, #56
167 ; CHECK-NEXT: shl.2d v2, v1, #56
168 ; CHECK-NEXT: sshr.2d v1, v0, #56
169 ; CHECK-NEXT: sshr.2d v0, v2, #56
172 %r = sext <4 x i8> %v0 to <4 x i64>
176 define <8 x i64> @zext_v8i8_to_v8i64(<8 x i8> %v0) nounwind {
177 ; CHECK-LABEL: zext_v8i8_to_v8i64:
178 ; CHECK-NEXT: ushll.8h v0, v0, #0
179 ; CHECK-NEXT: ushll2.4s v2, v0, #0
180 ; CHECK-NEXT: ushll.4s v0, v0, #0
181 ; CHECK-NEXT: ushll2.2d v3, v2, #0
182 ; CHECK-NEXT: ushll2.2d v1, v0, #0
183 ; CHECK-NEXT: ushll.2d v2, v2, #0
184 ; CHECK-NEXT: ushll.2d v0, v0, #0
187 %r = zext <8 x i8> %v0 to <8 x i64>
191 define <8 x i64> @sext_v8i8_to_v8i64(<8 x i8> %v0) nounwind {
192 ; CHECK-LABEL: sext_v8i8_to_v8i64:
193 ; CHECK-NEXT: sshll.8h v0, v0, #0
194 ; CHECK-NEXT: sshll2.4s v2, v0, #0
195 ; CHECK-NEXT: sshll.4s v0, v0, #0
196 ; CHECK-NEXT: sshll2.2d v3, v2, #0
197 ; CHECK-NEXT: sshll2.2d v1, v0, #0
198 ; CHECK-NEXT: sshll.2d v2, v2, #0
199 ; CHECK-NEXT: sshll.2d v0, v0, #0
202 %r = sext <8 x i8> %v0 to <8 x i64>
206 ; Extends of vectors of i1.
208 define <32 x i8> @zext_v32i1(<32 x i1> %arg) {
209 ; CHECK-LABEL: zext_v32i1:
210 ; CHECK: and.16b v0, v0, v2
211 ; CHECK-NEXT: and.16b v1, v1, v2
213 %res = zext <32 x i1> %arg to <32 x i8>
217 define <32 x i8> @sext_v32i1(<32 x i1> %arg) {
218 ; CHECK-LABEL: sext_v32i1:
219 ; CHECK: shl.16b v0, v0, #7
220 ; CHECK-NEXT: shl.16b v1, v1, #7
221 ; CHECK-NEXT: sshr.16b v0, v0, #7
222 ; CHECK-NEXT: sshr.16b v1, v1, #7
225 %res = sext <32 x i1> %arg to <32 x i8>
229 define <64 x i8> @zext_v64i1(<64 x i1> %arg) {
230 ; CHECK-LABEL: zext_v64i1:
231 ; CHECK: and.16b v0, v0, [[V4:v.+]]
232 ; CHECK-NEXT: and.16b v1, v1, [[V4]]
233 ; CHECK-NEXT: and.16b v2, v2, [[V4]]
234 ; CHECK-NEXT: and.16b v3, v3, [[V4]]
237 %res = zext <64 x i1> %arg to <64 x i8>
241 define <64 x i8> @sext_v64i1(<64 x i1> %arg) {
242 ; CHECK-LABEL: sext_v64i1:
243 ; CHECK: shl.16b v0, v0, #7
244 ; CHECK-NEXT: shl.16b v3, v3, #7
245 ; CHECK-NEXT: shl.16b v2, v2, #7
246 ; CHECK-NEXT: shl.16b [[V4:v.+]], v1, #7
247 ; CHECK-NEXT: sshr.16b v0, v0, #7
248 ; CHECK-NEXT: sshr.16b v1, v3, #7
249 ; CHECK-NEXT: sshr.16b v2, v2, #7
250 ; CHECK-NEXT: sshr.16b v3, [[V4]], #7
253 %res = sext <64 x i1> %arg to <64 x i8>
257 define <1 x i128> @sext_v1x64(<1 x i64> %arg) {
258 ; CHECK-LABEL: sext_v1x64:
259 ; CHECK-NEXT: .cfi_startproc
260 ; CHECK-NEXT: fmov x8, d0
261 ; CHECK-NEXT: asr x1, x8, #63
262 ; X0 & X1 are the real return registers, SDAG messes with v0 too for unknown reasons.
263 ; CHECK: {{(mov.d v0[1], x1)?}}
267 %res = sext <1 x i64> %arg to <1 x i128>