1; Test vector insertion of constants.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
4
5; Test v16i8 insertion into the first element.
6define <16 x i8> @f1(<16 x i8> %val) {
7; CHECK-LABEL: f1:
8; CHECK: vleib %v24, 0, 0
9; CHECK: br %r14
10  %ret = insertelement <16 x i8> %val, i8 0, i32 0
11  ret <16 x i8> %ret
12}
13
14; Test v16i8 insertion into the last element.
15define <16 x i8> @f2(<16 x i8> %val) {
16; CHECK-LABEL: f2:
17; CHECK: vleib %v24, 100, 15
18; CHECK: br %r14
19  %ret = insertelement <16 x i8> %val, i8 100, i32 15
20  ret <16 x i8> %ret
21}
22
23; Test v16i8 insertion with the maximum signed value.
24define <16 x i8> @f3(<16 x i8> %val) {
25; CHECK-LABEL: f3:
26; CHECK: vleib %v24, 127, 10
27; CHECK: br %r14
28  %ret = insertelement <16 x i8> %val, i8 127, i32 10
29  ret <16 x i8> %ret
30}
31
32; Test v16i8 insertion with the minimum signed value.
33define <16 x i8> @f4(<16 x i8> %val) {
34; CHECK-LABEL: f4:
35; CHECK: vleib %v24, -128, 11
36; CHECK: br %r14
37  %ret = insertelement <16 x i8> %val, i8 128, i32 11
38  ret <16 x i8> %ret
39}
40
41; Test v16i8 insertion with the maximum unsigned value.
42define <16 x i8> @f5(<16 x i8> %val) {
43; CHECK-LABEL: f5:
44; CHECK: vleib %v24, -1, 12
45; CHECK: br %r14
46  %ret = insertelement <16 x i8> %val, i8 255, i32 12
47  ret <16 x i8> %ret
48}
49
50; Test v16i8 insertion into a variable element.
51define <16 x i8> @f6(<16 x i8> %val, i32 %index) {
52; CHECK-LABEL: f6:
53; CHECK-NOT: vleib
54; CHECK: br %r14
55  %ret = insertelement <16 x i8> %val, i8 0, i32 %index
56  ret <16 x i8> %ret
57}
58
59; Test v8i16 insertion into the first element.
60define <8 x i16> @f7(<8 x i16> %val) {
61; CHECK-LABEL: f7:
62; CHECK: vleih %v24, 0, 0
63; CHECK: br %r14
64  %ret = insertelement <8 x i16> %val, i16 0, i32 0
65  ret <8 x i16> %ret
66}
67
68; Test v8i16 insertion into the last element.
69define <8 x i16> @f8(<8 x i16> %val) {
70; CHECK-LABEL: f8:
71; CHECK: vleih %v24, 0, 7
72; CHECK: br %r14
73  %ret = insertelement <8 x i16> %val, i16 0, i32 7
74  ret <8 x i16> %ret
75}
76
77; Test v8i16 insertion with the maximum signed value.
78define <8 x i16> @f9(<8 x i16> %val) {
79; CHECK-LABEL: f9:
80; CHECK: vleih %v24, 32767, 4
81; CHECK: br %r14
82  %ret = insertelement <8 x i16> %val, i16 32767, i32 4
83  ret <8 x i16> %ret
84}
85
86; Test v8i16 insertion with the minimum signed value.
87define <8 x i16> @f10(<8 x i16> %val) {
88; CHECK-LABEL: f10:
89; CHECK: vleih %v24, -32768, 5
90; CHECK: br %r14
91  %ret = insertelement <8 x i16> %val, i16 32768, i32 5
92  ret <8 x i16> %ret
93}
94
95; Test v8i16 insertion with the maximum unsigned value.
96define <8 x i16> @f11(<8 x i16> %val) {
97; CHECK-LABEL: f11:
98; CHECK: vleih %v24, -1, 6
99; CHECK: br %r14
100  %ret = insertelement <8 x i16> %val, i16 65535, i32 6
101  ret <8 x i16> %ret
102}
103
104; Test v8i16 insertion into a variable element.
105define <8 x i16> @f12(<8 x i16> %val, i32 %index) {
106; CHECK-LABEL: f12:
107; CHECK-NOT: vleih
108; CHECK: br %r14
109  %ret = insertelement <8 x i16> %val, i16 0, i32 %index
110  ret <8 x i16> %ret
111}
112
113; Test v4i32 insertion into the first element.
114define <4 x i32> @f13(<4 x i32> %val) {
115; CHECK-LABEL: f13:
116; CHECK: vleif %v24, 0, 0
117; CHECK: br %r14
118  %ret = insertelement <4 x i32> %val, i32 0, i32 0
119  ret <4 x i32> %ret
120}
121
122; Test v4i32 insertion into the last element.
123define <4 x i32> @f14(<4 x i32> %val) {
124; CHECK-LABEL: f14:
125; CHECK: vleif %v24, 0, 3
126; CHECK: br %r14
127  %ret = insertelement <4 x i32> %val, i32 0, i32 3
128  ret <4 x i32> %ret
129}
130
131; Test v4i32 insertion with the maximum value allowed by VLEIF.
132define <4 x i32> @f15(<4 x i32> %val) {
133; CHECK-LABEL: f15:
134; CHECK: vleif %v24, 32767, 1
135; CHECK: br %r14
136  %ret = insertelement <4 x i32> %val, i32 32767, i32 1
137  ret <4 x i32> %ret
138}
139
140; Test v4i32 insertion with the next value up.
141define <4 x i32> @f16(<4 x i32> %val) {
142; CHECK-LABEL: f16:
143; CHECK-NOT: vleif
144; CHECK: br %r14
145  %ret = insertelement <4 x i32> %val, i32 32768, i32 1
146  ret <4 x i32> %ret
147}
148
149; Test v4i32 insertion with the minimum value allowed by VLEIF.
150define <4 x i32> @f17(<4 x i32> %val) {
151; CHECK-LABEL: f17:
152; CHECK: vleif %v24, -32768, 2
153; CHECK: br %r14
154  %ret = insertelement <4 x i32> %val, i32 -32768, i32 2
155  ret <4 x i32> %ret
156}
157
158; Test v4i32 insertion with the next value down.
159define <4 x i32> @f18(<4 x i32> %val) {
160; CHECK-LABEL: f18:
161; CHECK-NOT: vleif
162; CHECK: br %r14
163  %ret = insertelement <4 x i32> %val, i32 -32769, i32 2
164  ret <4 x i32> %ret
165}
166
167; Test v4i32 insertion into a variable element.
168define <4 x i32> @f19(<4 x i32> %val, i32 %index) {
169; CHECK-LABEL: f19:
170; CHECK-NOT: vleif
171; CHECK: br %r14
172  %ret = insertelement <4 x i32> %val, i32 0, i32 %index
173  ret <4 x i32> %ret
174}
175
176; Test v2i64 insertion into the first element.
177define <2 x i64> @f20(<2 x i64> %val) {
178; CHECK-LABEL: f20:
179; CHECK: vleig %v24, 0, 0
180; CHECK: br %r14
181  %ret = insertelement <2 x i64> %val, i64 0, i32 0
182  ret <2 x i64> %ret
183}
184
185; Test v2i64 insertion into the last element.
186define <2 x i64> @f21(<2 x i64> %val) {
187; CHECK-LABEL: f21:
188; CHECK: vleig %v24, 0, 1
189; CHECK: br %r14
190  %ret = insertelement <2 x i64> %val, i64 0, i32 1
191  ret <2 x i64> %ret
192}
193
194; Test v2i64 insertion with the maximum value allowed by VLEIG.
195define <2 x i64> @f22(<2 x i64> %val) {
196; CHECK-LABEL: f22:
197; CHECK: vleig %v24, 32767, 1
198; CHECK: br %r14
199  %ret = insertelement <2 x i64> %val, i64 32767, i32 1
200  ret <2 x i64> %ret
201}
202
203; Test v2i64 insertion with the next value up.
204define <2 x i64> @f23(<2 x i64> %val) {
205; CHECK-LABEL: f23:
206; CHECK-NOT: vleig
207; CHECK: br %r14
208  %ret = insertelement <2 x i64> %val, i64 32768, i32 1
209  ret <2 x i64> %ret
210}
211
212; Test v2i64 insertion with the minimum value allowed by VLEIG.
213define <2 x i64> @f24(<2 x i64> %val) {
214; CHECK-LABEL: f24:
215; CHECK: vleig %v24, -32768, 0
216; CHECK: br %r14
217  %ret = insertelement <2 x i64> %val, i64 -32768, i32 0
218  ret <2 x i64> %ret
219}
220
221; Test v2i64 insertion with the next value down.
222define <2 x i64> @f25(<2 x i64> %val) {
223; CHECK-LABEL: f25:
224; CHECK-NOT: vleig
225; CHECK: br %r14
226  %ret = insertelement <2 x i64> %val, i64 -32769, i32 0
227  ret <2 x i64> %ret
228}
229
230; Test v2i64 insertion into a variable element.
231define <2 x i64> @f26(<2 x i64> %val, i32 %index) {
232; CHECK-LABEL: f26:
233; CHECK-NOT: vleig
234; CHECK: br %r14
235  %ret = insertelement <2 x i64> %val, i64 0, i32 %index
236  ret <2 x i64> %ret
237}
238
239; Test v4f32 insertion of 0 into the first element.
240define <4 x float> @f27(<4 x float> %val) {
241; CHECK-LABEL: f27:
242; CHECK: vleif %v24, 0, 0
243; CHECK: br %r14
244  %ret = insertelement <4 x float> %val, float 0.0, i32 0
245  ret <4 x float> %ret
246}
247
248; Test v4f32 insertion of 0 into the last element.
249define <4 x float> @f28(<4 x float> %val) {
250; CHECK-LABEL: f28:
251; CHECK: vleif %v24, 0, 3
252; CHECK: br %r14
253  %ret = insertelement <4 x float> %val, float 0.0, i32 3
254  ret <4 x float> %ret
255}
256
257; Test v4f32 insertion of a nonzero value.
258define <4 x float> @f29(<4 x float> %val) {
259; CHECK-LABEL: f29:
260; CHECK-NOT: vleif
261; CHECK: br %r14
262  %ret = insertelement <4 x float> %val, float 1.0, i32 1
263  ret <4 x float> %ret
264}
265
266; Test v2f64 insertion of 0 into the first element.
267define <2 x double> @f30(<2 x double> %val) {
268; CHECK-LABEL: f30:
269; CHECK: vleig %v24, 0, 0
270; CHECK: br %r14
271  %ret = insertelement <2 x double> %val, double 0.0, i32 0
272  ret <2 x double> %ret
273}
274
275; Test v2f64 insertion of 0 into the last element.
276define <2 x double> @f31(<2 x double> %val) {
277; CHECK-LABEL: f31:
278; CHECK: vleig %v24, 0, 1
279; CHECK: br %r14
280  %ret = insertelement <2 x double> %val, double 0.0, i32 1
281  ret <2 x double> %ret
282}
283
284; Test v2f64 insertion of a nonzero value.
285define <2 x double> @f32(<2 x double> %val) {
286; CHECK-LABEL: f32:
287; CHECK-NOT: vleig
288; CHECK: br %r14
289  %ret = insertelement <2 x double> %val, double 1.0, i32 1
290  ret <2 x double> %ret
291}
292