1 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
3 ; Check that building up a vector w/ only one non-zero lane initializes
6 define <8 x i8> @v8i8z(i8 %t, i8 %s) nounwind {
7 %v = insertelement <8 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 undef>, i8 %s, i32 7
11 ; CHECK: movi d[[R:[0-9]+]], #0
12 ; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
15 define <16 x i8> @v16i8z(i8 %t, i8 %s) nounwind {
16 %v = insertelement <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 undef>, i8 %s, i32 15
19 ; CHECK-LABEL: v16i8z:
20 ; CHECK: movi v[[R:[0-9]+]].2d, #0
21 ; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
24 define <4 x i16> @v4i16z(i16 %t, i16 %s) nounwind {
25 %v = insertelement <4 x i16> <i16 0, i16 0, i16 0, i16 undef>, i16 %s, i32 3
28 ; CHECK-LABEL: v4i16z:
29 ; CHECK: movi d[[R:[0-9]+]], #0
30 ; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
33 define <8 x i16> @v8i16z(i16 %t, i16 %s) nounwind {
34 %v = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 undef>, i16 %s, i32 7
37 ; CHECK-LABEL: v8i16z:
38 ; CHECK: movi v[[R:[0-9]+]].2d, #0
39 ; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
42 define <2 x i32> @v2i32z(i32 %t, i32 %s) nounwind {
43 %v = insertelement <2 x i32> <i32 0, i32 undef>, i32 %s, i32 1
46 ; CHECK-LABEL: v2i32z:
47 ; CHECK: movi d[[R:[0-9]+]], #0
48 ; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
51 define <4 x i32> @v4i32z(i32 %t, i32 %s) nounwind {
52 %v = insertelement <4 x i32> <i32 0, i32 0, i32 0, i32 undef>, i32 %s, i32 3
55 ; CHECK-LABEL: v4i32z:
56 ; CHECK: movi v[[R:[0-9]+]].2d, #0
57 ; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
60 define <2 x i64> @v2i64z(i64 %t, i64 %s) nounwind {
61 %v = insertelement <2 x i64> <i64 0, i64 undef>, i64 %s, i32 1
64 ; CHECK-LABEL: v2i64z:
65 ; CHECK: movi v[[R:[0-9]+]].2d, #0
66 ; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
69 define <2 x float> @v2f32z(float %t, float %s) nounwind {
70 %v = insertelement <2 x float> <float 0.0, float undef>, float %s, i32 1
73 ; CHECK-LABEL: v2f32z:
74 ; CHECK: movi d[[R:[0-9]+]], #0
75 ; CHECK: mov v[[R]].s[1], v{{[0-9]+}}.s[0]
78 define <4 x float> @v4f32z(float %t, float %s) nounwind {
79 %v = insertelement <4 x float> <float 0.0, float 0.0, float 0.0, float undef>, float %s, i32 3
82 ; CHECK-LABEL: v4f32z:
83 ; CHECK: movi v[[R:[0-9]+]].2d, #0
84 ; CHECK: mov v[[R]].s[3], v{{[0-9]+}}.s[0]
87 define <2 x double> @v2f64z(double %t, double %s) nounwind {
88 %v = insertelement <2 x double> <double 0.0, double undef>, double %s, i32 1
91 ; CHECK-LABEL: v2f64z:
92 ; CHECK: movi v[[R:[0-9]+]].2d, #0
93 ; CHECK: mov v[[R]].d[1], v{{[0-9]+}}.d[0]
96 ; Check that building up a vector w/ only one non-ones lane initializes
99 define <8 x i8> @v8i8m(i8 %t, i8 %s) nounwind {
100 %v = insertelement <8 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 undef>, i8 %s, i32 7
104 ; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
105 ; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
108 define <16 x i8> @v16i8m(i8 %t, i8 %s) nounwind {
109 %v = insertelement <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 undef>, i8 %s, i32 15
112 ; CHECK-LABEL: v16i8m
113 ; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
114 ; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
117 define <4 x i16> @v4i16m(i16 %t, i16 %s) nounwind {
118 %v = insertelement <4 x i16> <i16 -1, i16 -1, i16 -1, i16 undef>, i16 %s, i32 3
121 ; CHECK-LABEL: v4i16m
122 ; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
123 ; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
126 define <8 x i16> @v8i16m(i16 %t, i16 %s) nounwind {
127 %v = insertelement <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 undef>, i16 %s, i32 7
130 ; CHECK-LABEL: v8i16m
131 ; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
132 ; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
135 define <2 x i32> @v2i32m(i32 %t, i32 %s) nounwind {
136 %v = insertelement <2 x i32> <i32 -1, i32 undef>, i32 %s, i32 1
139 ; CHECK-LABEL: v2i32m
140 ; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
141 ; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
144 define <4 x i32> @v4i32m(i32 %t, i32 %s) nounwind {
145 %v = insertelement <4 x i32> <i32 -1, i32 -1, i32 -1, i32 undef>, i32 %s, i32 3
148 ; CHECK-LABEL: v4i32m
149 ; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
150 ; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
153 define <2 x i64> @v2i64m(i64 %t, i64 %s) nounwind {
154 %v = insertelement <2 x i64> <i64 -1, i64 undef>, i64 %s, i32 1
157 ; CHECK-LABEL: v2i64m
158 ; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
159 ; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
162 ; Check that building up a vector w/ some constants initializes efficiently.
164 define void @v8i8st(<8 x i8>* %p, i8 %s) nounwind {
165 %v = insertelement <8 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 undef>, i8 %s, i32 7
166 store <8 x i8> %v, <8 x i8>* %p, align 8
169 ; CHECK-LABEL: v8i8st:
170 ; CHECK: movi v[[R:[0-9]+]].8b, #1
171 ; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
172 ; CHECK: str d[[R]], [x{{[0-9]+}}]
175 define void @v16i8st(<16 x i8>* %p, i8 %s) nounwind {
176 %v = insertelement <16 x i8> <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 undef>, i8 %s, i32 15
177 store <16 x i8> %v, <16 x i8>* %p, align 16
180 ; CHECK-LABEL: v16i8st:
181 ; CHECK: movi v[[R:[0-9]+]].16b, #128
182 ; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
183 ; CHECK: str q[[R]], [x{{[0-9]+}}]
186 define void @v4i16st(<4 x i16>* %p, i16 %s) nounwind {
187 %v = insertelement <4 x i16> <i16 21760, i16 21760, i16 21760, i16 undef>, i16 %s, i32 3
188 store <4 x i16> %v, <4 x i16>* %p, align 8
191 ; CHECK-LABEL: v4i16st:
192 ; CHECK: movi v[[R:[0-9]+]].4h, #85, lsl #8
193 ; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
194 ; CHECK: str d[[R]], [x{{[0-9]+}}]
197 define void @v8i16st(<8 x i16>* %p, i16 %s) nounwind {
198 %v = insertelement <8 x i16> <i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 undef>, i16 %s, i32 7
199 store <8 x i16> %v, <8 x i16>* %p, align 16
202 ; CHECK-LABEL: v8i16st:
203 ; CHECK: mvni v[[R:[0-9]+]].8h, #85, lsl #8
204 ; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
205 ; CHECK: str q[[R]], [x{{[0-9]+}}]
208 define void @v2i32st(<2 x i32>* %p, i32 %s) nounwind {
209 %v = insertelement <2 x i32> <i32 983040, i32 undef>, i32 %s, i32 1
210 store <2 x i32> %v, <2 x i32>* %p, align 8
213 ; CHECK-LABEL: v2i32st:
214 ; CHECK: movi v[[R:[0-9]+]].2s, #15, lsl #16
215 ; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
216 ; CHECK: str d[[R]], [x{{[0-9]+}}]
219 define void @v4i32st(<4 x i32>* %p, i32 %s) nounwind {
220 %v = insertelement <4 x i32> <i32 16318463, i32 16318463, i32 16318463, i32 undef>, i32 %s, i32 3
221 store <4 x i32> %v, <4 x i32>* %p, align 16
224 ; CHECK-LABEL: v4i32st:
225 ; CHECK: movi v[[R:[0-9]+]].4s, #248, msl #16
226 ; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
227 ; CHECK: str q[[R]], [x{{[0-9]+}}]
230 define void @v2i64st(<2 x i64>* %p, i64 %s) nounwind {
231 %v = insertelement <2 x i64> <i64 13835058055282163712, i64 undef>, i64 %s, i32 1
232 store <2 x i64> %v, <2 x i64>* %p, align 16
235 ; CHECK-LABEL: v2i64st:
236 ; CHECK: fmov v[[R:[0-9]+]].2d, #-2.0
237 ; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
238 ; CHECK: str q[[R]], [x{{[0-9]+}}]
241 define void @v2f32st(<2 x float>* %p, float %s) nounwind {
242 %v = insertelement <2 x float> <float 2.0, float undef>, float %s, i32 1
243 store <2 x float> %v, <2 x float>* %p, align 8
246 ; CHECK-LABEL: v2f32st:
247 ; CHECK: movi v[[R:[0-9]+]].2s, #64, lsl #24
248 ; CHECK: mov v[[R]].s[1], v{{[0-9]+}}.s[0]
249 ; CHECK: str d[[R]], [x{{[0-9]+}}]
252 define void @v4f32st(<4 x float>* %p, float %s) nounwind {
253 %v = insertelement <4 x float> <float -2.0, float -2.0, float -2.0, float undef>, float %s, i32 3
254 store <4 x float> %v, <4 x float>* %p, align 16
257 ; CHECK-LABEL: v4f32st:
258 ; CHECK: movi v[[R:[0-9]+]].4s, #192, lsl #24
259 ; CHECK: mov v[[R]].s[3], v{{[0-9]+}}.s[0]
260 ; CHECK: str q[[R]], [x{{[0-9]+}}]
263 define void @v2f64st(<2 x double>* %p, double %s) nounwind {
264 %v = insertelement <2 x double> <double 2.0, double undef>, double %s, i32 1
265 store <2 x double> %v, <2 x double>* %p, align 16
268 ; CHECK-LABEL: v2f64st:
269 ; CHECK: fmov v[[R:[0-9]+]].2d, #2.0
270 ; CHECK: mov v[[R]].d[1], v{{[0-9]+}}.d[0]
271 ; CHECK: str q[[R]], [x{{[0-9]+}}]