1 ; Test vector insertion of memory values.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5 ; Test v16i8 insertion into the first element.
6 define <16 x i8> @f1(<16 x i8> %val, i8 *%ptr) {
8 ; CHECK: vleb %v24, 0(%r2), 0
10 %element = load i8, i8 *%ptr
11 %ret = insertelement <16 x i8> %val, i8 %element, i32 0
15 ; Test v16i8 insertion into the last element.
16 define <16 x i8> @f2(<16 x i8> %val, i8 *%ptr) {
18 ; CHECK: vleb %v24, 0(%r2), 15
20 %element = load i8, i8 *%ptr
21 %ret = insertelement <16 x i8> %val, i8 %element, i32 15
25 ; Test v16i8 insertion with the highest in-range offset.
26 define <16 x i8> @f3(<16 x i8> %val, i8 *%base) {
28 ; CHECK: vleb %v24, 4095(%r2), 10
30 %ptr = getelementptr i8, i8 *%base, i32 4095
31 %element = load i8, i8 *%ptr
32 %ret = insertelement <16 x i8> %val, i8 %element, i32 10
36 ; Test v16i8 insertion with the first ouf-of-range offset.
37 define <16 x i8> @f4(<16 x i8> %val, i8 *%base) {
39 ; CHECK: aghi %r2, 4096
40 ; CHECK: vleb %v24, 0(%r2), 5
42 %ptr = getelementptr i8, i8 *%base, i32 4096
43 %element = load i8, i8 *%ptr
44 %ret = insertelement <16 x i8> %val, i8 %element, i32 5
48 ; Test v16i8 insertion into a variable element.
49 define <16 x i8> @f5(<16 x i8> %val, i8 *%ptr, i32 %index) {
53 %element = load i8, i8 *%ptr
54 %ret = insertelement <16 x i8> %val, i8 %element, i32 %index
58 ; Test v8i16 insertion into the first element.
59 define <8 x i16> @f6(<8 x i16> %val, i16 *%ptr) {
61 ; CHECK: vleh %v24, 0(%r2), 0
63 %element = load i16, i16 *%ptr
64 %ret = insertelement <8 x i16> %val, i16 %element, i32 0
68 ; Test v8i16 insertion into the last element.
69 define <8 x i16> @f7(<8 x i16> %val, i16 *%ptr) {
71 ; CHECK: vleh %v24, 0(%r2), 7
73 %element = load i16, i16 *%ptr
74 %ret = insertelement <8 x i16> %val, i16 %element, i32 7
78 ; Test v8i16 insertion with the highest in-range offset.
79 define <8 x i16> @f8(<8 x i16> %val, i16 *%base) {
81 ; CHECK: vleh %v24, 4094(%r2), 5
83 %ptr = getelementptr i16, i16 *%base, i32 2047
84 %element = load i16, i16 *%ptr
85 %ret = insertelement <8 x i16> %val, i16 %element, i32 5
89 ; Test v8i16 insertion with the first ouf-of-range offset.
90 define <8 x i16> @f9(<8 x i16> %val, i16 *%base) {
92 ; CHECK: aghi %r2, 4096
93 ; CHECK: vleh %v24, 0(%r2), 1
95 %ptr = getelementptr i16, i16 *%base, i32 2048
96 %element = load i16, i16 *%ptr
97 %ret = insertelement <8 x i16> %val, i16 %element, i32 1
101 ; Test v8i16 insertion into a variable element.
102 define <8 x i16> @f10(<8 x i16> %val, i16 *%ptr, i32 %index) {
106 %element = load i16, i16 *%ptr
107 %ret = insertelement <8 x i16> %val, i16 %element, i32 %index
111 ; Test v4i32 insertion into the first element.
112 define <4 x i32> @f11(<4 x i32> %val, i32 *%ptr) {
114 ; CHECK: vlef %v24, 0(%r2), 0
116 %element = load i32, i32 *%ptr
117 %ret = insertelement <4 x i32> %val, i32 %element, i32 0
121 ; Test v4i32 insertion into the last element.
122 define <4 x i32> @f12(<4 x i32> %val, i32 *%ptr) {
124 ; CHECK: vlef %v24, 0(%r2), 3
126 %element = load i32, i32 *%ptr
127 %ret = insertelement <4 x i32> %val, i32 %element, i32 3
131 ; Test v4i32 insertion with the highest in-range offset.
132 define <4 x i32> @f13(<4 x i32> %val, i32 *%base) {
134 ; CHECK: vlef %v24, 4092(%r2), 2
136 %ptr = getelementptr i32, i32 *%base, i32 1023
137 %element = load i32, i32 *%ptr
138 %ret = insertelement <4 x i32> %val, i32 %element, i32 2
142 ; Test v4i32 insertion with the first ouf-of-range offset.
143 define <4 x i32> @f14(<4 x i32> %val, i32 *%base) {
145 ; CHECK: aghi %r2, 4096
146 ; CHECK: vlef %v24, 0(%r2), 1
148 %ptr = getelementptr i32, i32 *%base, i32 1024
149 %element = load i32, i32 *%ptr
150 %ret = insertelement <4 x i32> %val, i32 %element, i32 1
154 ; Test v4i32 insertion into a variable element.
155 define <4 x i32> @f15(<4 x i32> %val, i32 *%ptr, i32 %index) {
159 %element = load i32, i32 *%ptr
160 %ret = insertelement <4 x i32> %val, i32 %element, i32 %index
164 ; Test v2i64 insertion into the first element.
165 define <2 x i64> @f16(<2 x i64> %val, i64 *%ptr) {
167 ; CHECK: vleg %v24, 0(%r2), 0
169 %element = load i64, i64 *%ptr
170 %ret = insertelement <2 x i64> %val, i64 %element, i32 0
174 ; Test v2i64 insertion into the last element.
175 define <2 x i64> @f17(<2 x i64> %val, i64 *%ptr) {
177 ; CHECK: vleg %v24, 0(%r2), 1
179 %element = load i64, i64 *%ptr
180 %ret = insertelement <2 x i64> %val, i64 %element, i32 1
184 ; Test v2i64 insertion with the highest in-range offset.
185 define <2 x i64> @f18(<2 x i64> %val, i64 *%base) {
187 ; CHECK: vleg %v24, 4088(%r2), 1
189 %ptr = getelementptr i64, i64 *%base, i32 511
190 %element = load i64, i64 *%ptr
191 %ret = insertelement <2 x i64> %val, i64 %element, i32 1
195 ; Test v2i64 insertion with the first ouf-of-range offset.
196 define <2 x i64> @f19(<2 x i64> %val, i64 *%base) {
198 ; CHECK: aghi %r2, 4096
199 ; CHECK: vleg %v24, 0(%r2), 0
201 %ptr = getelementptr i64, i64 *%base, i32 512
202 %element = load i64, i64 *%ptr
203 %ret = insertelement <2 x i64> %val, i64 %element, i32 0
207 ; Test v2i64 insertion into a variable element.
208 define <2 x i64> @f20(<2 x i64> %val, i64 *%ptr, i32 %index) {
212 %element = load i64, i64 *%ptr
213 %ret = insertelement <2 x i64> %val, i64 %element, i32 %index
217 ; Test a v4i32 gather of the first element.
218 define <4 x i32> @f31(<4 x i32> %val, <4 x i32> %index, i64 %base) {
220 ; CHECK: vgef %v24, 0(%v26,%r2), 0
222 %elem = extractelement <4 x i32> %index, i32 0
223 %ext = zext i32 %elem to i64
224 %add = add i64 %base, %ext
225 %ptr = inttoptr i64 %add to i32 *
226 %element = load i32, i32 *%ptr
227 %ret = insertelement <4 x i32> %val, i32 %element, i32 0
231 ; Test a v4i32 gather of the last element.
232 define <4 x i32> @f32(<4 x i32> %val, <4 x i32> %index, i64 %base) {
234 ; CHECK: vgef %v24, 0(%v26,%r2), 3
236 %elem = extractelement <4 x i32> %index, i32 3
237 %ext = zext i32 %elem to i64
238 %add = add i64 %base, %ext
239 %ptr = inttoptr i64 %add to i32 *
240 %element = load i32, i32 *%ptr
241 %ret = insertelement <4 x i32> %val, i32 %element, i32 3
245 ; Test a v4i32 gather with the highest in-range offset.
246 define <4 x i32> @f33(<4 x i32> %val, <4 x i32> %index, i64 %base) {
248 ; CHECK: vgef %v24, 4095(%v26,%r2), 1
250 %elem = extractelement <4 x i32> %index, i32 1
251 %ext = zext i32 %elem to i64
252 %add1 = add i64 %base, %ext
253 %add2 = add i64 %add1, 4095
254 %ptr = inttoptr i64 %add2 to i32 *
255 %element = load i32, i32 *%ptr
256 %ret = insertelement <4 x i32> %val, i32 %element, i32 1
260 ; Test a v2i64 gather of the first element.
261 define <2 x i64> @f34(<2 x i64> %val, <2 x i64> %index, i64 %base) {
263 ; CHECK: vgeg %v24, 0(%v26,%r2), 0
265 %elem = extractelement <2 x i64> %index, i32 0
266 %add = add i64 %base, %elem
267 %ptr = inttoptr i64 %add to i64 *
268 %element = load i64, i64 *%ptr
269 %ret = insertelement <2 x i64> %val, i64 %element, i32 0
273 ; Test a v2i64 gather of the last element.
274 define <2 x i64> @f35(<2 x i64> %val, <2 x i64> %index, i64 %base) {
276 ; CHECK: vgeg %v24, 0(%v26,%r2), 1
278 %elem = extractelement <2 x i64> %index, i32 1
279 %add = add i64 %base, %elem
280 %ptr = inttoptr i64 %add to i64 *
281 %element = load i64, i64 *%ptr
282 %ret = insertelement <2 x i64> %val, i64 %element, i32 1