1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; Test 128-bit arithmetic in vector registers on z13
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
6 ; Sign extension from i64.
7 define i128 @f1(i64 %a) {
10 ; CHECK-NEXT: srag %r0, %r3, 63
11 ; CHECK-NEXT: vlvgp %v0, %r0, %r3
12 ; CHECK-NEXT: vst %v0, 0(%r2), 3
14 %res = sext i64 %a to i128
18 ; Sign extension from i64 from memory.
19 define i128 @f2(ptr %ptr) {
22 ; CHECK-NEXT: vlrepg %v0, 0(%r3)
23 ; CHECK-NEXT: vrepib %v1, 64
24 ; CHECK-NEXT: vsrab %v0, %v0, %v1
25 ; CHECK-NEXT: vst %v0, 0(%r2), 3
27 %a = load i64, ptr %ptr
28 %res = sext i64 %a to i128
32 ; Zero extension from i64.
33 define i128 @f3(i64 %a) {
36 ; CHECK-NEXT: vgbm %v0, 0
37 ; CHECK-NEXT: vlvgg %v0, %r3, 1
38 ; CHECK-NEXT: vst %v0, 0(%r2), 3
40 %res = zext i64 %a to i128
44 ; Zero extension from i64 from memory.
45 define i128 @f4(ptr %ptr) {
48 ; CHECK-NEXT: vgbm %v0, 0
49 ; CHECK-NEXT: vleg %v0, 0(%r3), 1
50 ; CHECK-NEXT: vst %v0, 0(%r2), 3
52 %a = load i64, ptr %ptr
53 %res = zext i64 %a to i128
58 define i64 @f5(i128 %a) {
61 ; CHECK-NEXT: vl %v0, 0(%r2), 3
62 ; CHECK-NEXT: vaq %v0, %v0, %v0
63 ; CHECK-NEXT: vlgvg %r2, %v0, 1
66 %res = trunc i128 %op to i64
70 ; Truncation to i64 in memory.
71 define void @f6(ptr %ptr, i128 %a) {
74 ; CHECK-NEXT: vl %v0, 0(%r3), 3
75 ; CHECK-NEXT: vaq %v0, %v0, %v0
76 ; CHECK-NEXT: vsteg %v0, 0(%r2), 1
79 %res = trunc i128 %op to i64
80 store i64 %res, ptr %ptr
84 ; Sign extension from i32.
85 define i128 @f7(i32 %a) {
88 ; CHECK-NEXT: lgfr %r0, %r3
89 ; CHECK-NEXT: srag %r1, %r0, 63
90 ; CHECK-NEXT: vlvgp %v0, %r1, %r0
91 ; CHECK-NEXT: vst %v0, 0(%r2), 3
93 %res = sext i32 %a to i128
97 ; Sign extension from i32 from memory.
98 define i128 @f8(ptr %ptr) {
101 ; CHECK-NEXT: vlrepf %v0, 0(%r3)
102 ; CHECK-NEXT: vrepib %v1, 96
103 ; CHECK-NEXT: vsrab %v0, %v0, %v1
104 ; CHECK-NEXT: vst %v0, 0(%r2), 3
105 ; CHECK-NEXT: br %r14
106 %a = load i32, ptr %ptr
107 %res = sext i32 %a to i128
111 ; Zero extension from i32.
112 define i128 @f9(i32 %a) {
115 ; CHECK-NEXT: vgbm %v0, 0
116 ; CHECK-NEXT: vlvgf %v0, %r3, 3
117 ; CHECK-NEXT: vst %v0, 0(%r2), 3
118 ; CHECK-NEXT: br %r14
119 %res = zext i32 %a to i128
123 ; Zero extension from i32 from memory.
124 define i128 @f10(ptr %ptr) {
127 ; CHECK-NEXT: vgbm %v0, 0
128 ; CHECK-NEXT: vlef %v0, 0(%r3), 3
129 ; CHECK-NEXT: vst %v0, 0(%r2), 3
130 ; CHECK-NEXT: br %r14
131 %a = load i32, ptr %ptr
132 %res = zext i32 %a to i128
137 define i32 @f11(i128 %a) {
140 ; CHECK-NEXT: vl %v0, 0(%r2), 3
141 ; CHECK-NEXT: vaq %v0, %v0, %v0
142 ; CHECK-NEXT: vlgvf %r2, %v0, 3
143 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
144 ; CHECK-NEXT: br %r14
145 %op = add i128 %a, %a
146 %res = trunc i128 %op to i32
150 ; Truncation to i32 in memory.
151 define void @f12(ptr %ptr, i128 %a) {
154 ; CHECK-NEXT: vl %v0, 0(%r3), 3
155 ; CHECK-NEXT: vaq %v0, %v0, %v0
156 ; CHECK-NEXT: vstef %v0, 0(%r2), 3
157 ; CHECK-NEXT: br %r14
158 %op = add i128 %a, %a
159 %res = trunc i128 %op to i32
160 store i32 %res, ptr %ptr
164 ; Sign extension from i16.
165 define i128 @f13(i16 %a) {
168 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
169 ; CHECK-NEXT: lghr %r0, %r3
170 ; CHECK-NEXT: srag %r1, %r0, 63
171 ; CHECK-NEXT: vlvgp %v0, %r1, %r0
172 ; CHECK-NEXT: vst %v0, 0(%r2), 3
173 ; CHECK-NEXT: br %r14
174 %res = sext i16 %a to i128
178 ; Sign extension from i16 from memory.
179 define i128 @f14(ptr %ptr) {
182 ; CHECK-NEXT: vlreph %v0, 0(%r3)
183 ; CHECK-NEXT: vrepib %v1, 112
184 ; CHECK-NEXT: vsrab %v0, %v0, %v1
185 ; CHECK-NEXT: vst %v0, 0(%r2), 3
186 ; CHECK-NEXT: br %r14
187 %a = load i16, ptr %ptr
188 %res = sext i16 %a to i128
192 ; Zero extension from i16.
193 define i128 @f15(i16 %a) {
196 ; CHECK-NEXT: vgbm %v0, 0
197 ; CHECK-NEXT: vlvgh %v0, %r3, 7
198 ; CHECK-NEXT: vst %v0, 0(%r2), 3
199 ; CHECK-NEXT: br %r14
200 %res = zext i16 %a to i128
204 ; Zero extension from i16 from memory.
205 define i128 @f16(ptr %ptr) {
208 ; CHECK-NEXT: vgbm %v0, 0
209 ; CHECK-NEXT: vleh %v0, 0(%r3), 7
210 ; CHECK-NEXT: vst %v0, 0(%r2), 3
211 ; CHECK-NEXT: br %r14
212 %a = load i16, ptr %ptr
213 %res = zext i16 %a to i128
218 define i16 @f17(i128 %a) {
221 ; CHECK-NEXT: vl %v0, 0(%r2), 3
222 ; CHECK-NEXT: vaq %v0, %v0, %v0
223 ; CHECK-NEXT: vlgvf %r2, %v0, 3
224 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
225 ; CHECK-NEXT: br %r14
226 %op = add i128 %a, %a
227 %res = trunc i128 %op to i16
231 ; Truncation to i16 in memory.
232 define void @f18(ptr %ptr, i128 %a) {
235 ; CHECK-NEXT: vl %v0, 0(%r3), 3
236 ; CHECK-NEXT: vaq %v0, %v0, %v0
237 ; CHECK-NEXT: vsteh %v0, 0(%r2), 7
238 ; CHECK-NEXT: br %r14
239 %op = add i128 %a, %a
240 %res = trunc i128 %op to i16
241 store i16 %res, ptr %ptr
245 ; Sign extension from i8.
246 define i128 @f19(i8 %a) {
249 ; CHECK-NEXT: # kill: def $r3l killed $r3l def $r3d
250 ; CHECK-NEXT: lgbr %r0, %r3
251 ; CHECK-NEXT: srag %r1, %r0, 63
252 ; CHECK-NEXT: vlvgp %v0, %r1, %r0
253 ; CHECK-NEXT: vst %v0, 0(%r2), 3
254 ; CHECK-NEXT: br %r14
255 %res = sext i8 %a to i128
259 ; Sign extension from i8 from memory.
260 define i128 @f20(ptr %ptr) {
263 ; CHECK-NEXT: vlrepb %v0, 0(%r3)
264 ; CHECK-NEXT: vrepib %v1, 120
265 ; CHECK-NEXT: vsrab %v0, %v0, %v1
266 ; CHECK-NEXT: vst %v0, 0(%r2), 3
267 ; CHECK-NEXT: br %r14
268 %a = load i8, ptr %ptr
269 %res = sext i8 %a to i128
273 ; Zero extension from i8.
274 define i128 @f21(i8 %a) {
277 ; CHECK-NEXT: vgbm %v0, 0
278 ; CHECK-NEXT: vlvgb %v0, %r3, 15
279 ; CHECK-NEXT: vst %v0, 0(%r2), 3
280 ; CHECK-NEXT: br %r14
281 %res = zext i8 %a to i128
285 ; Zero extension from i8 from memory.
286 define i128 @f22(ptr %ptr) {
289 ; CHECK-NEXT: vgbm %v0, 0
290 ; CHECK-NEXT: vleb %v0, 0(%r3), 15
291 ; CHECK-NEXT: vst %v0, 0(%r2), 3
292 ; CHECK-NEXT: br %r14
293 %a = load i8, ptr %ptr
294 %res = zext i8 %a to i128
299 define i8 @f23(i128 %a) {
302 ; CHECK-NEXT: vl %v0, 0(%r2), 3
303 ; CHECK-NEXT: vaq %v0, %v0, %v0
304 ; CHECK-NEXT: vlgvf %r2, %v0, 3
305 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
306 ; CHECK-NEXT: br %r14
307 %op = add i128 %a, %a
308 %res = trunc i128 %op to i8
312 ; Truncation to i8 in memory.
313 define void @f24(ptr %ptr, i128 %a) {
316 ; CHECK-NEXT: vl %v0, 0(%r3), 3
317 ; CHECK-NEXT: vaq %v0, %v0, %v0
318 ; CHECK-NEXT: vsteb %v0, 0(%r2), 15
319 ; CHECK-NEXT: br %r14
320 %op = add i128 %a, %a
321 %res = trunc i128 %op to i8
322 store i8 %res, ptr %ptr
326 ; Sign extension from i1.
327 define i128 @f25(i1 %a) {
330 ; CHECK-NEXT: larl %r1, .LCPI24_0
331 ; CHECK-NEXT: vl %v1, 0(%r1), 3
332 ; CHECK-NEXT: vlvgp %v0, %r3, %r3
333 ; CHECK-NEXT: vn %v0, %v0, %v1
334 ; CHECK-NEXT: vgbm %v1, 0
335 ; CHECK-NEXT: vsq %v0, %v1, %v0
336 ; CHECK-NEXT: vst %v0, 0(%r2), 3
337 ; CHECK-NEXT: br %r14
338 %res = sext i1 %a to i128
342 ; Sign extension from i1 from memory.
343 define i128 @f26(ptr %ptr) {
346 ; CHECK-NEXT: vgbm %v1, 0
347 ; CHECK-NEXT: vleb %v1, 0(%r3), 15
348 ; CHECK-NEXT: larl %r1, .LCPI25_0
349 ; CHECK-NEXT: vl %v2, 0(%r1), 3
350 ; CHECK-NEXT: vgbm %v0, 0
351 ; CHECK-NEXT: vn %v1, %v1, %v2
352 ; CHECK-NEXT: vsq %v0, %v0, %v1
353 ; CHECK-NEXT: vst %v0, 0(%r2), 3
354 ; CHECK-NEXT: br %r14
355 %a = load i1, ptr %ptr
356 %res = sext i1 %a to i128
360 ; Zero extension from i1.
361 define i128 @f27(i1 %a) {
364 ; CHECK-NEXT: larl %r1, .LCPI26_0
365 ; CHECK-NEXT: vl %v1, 0(%r1), 3
366 ; CHECK-NEXT: vlvgp %v0, %r3, %r3
367 ; CHECK-NEXT: vn %v0, %v0, %v1
368 ; CHECK-NEXT: vst %v0, 0(%r2), 3
369 ; CHECK-NEXT: br %r14
370 %res = zext i1 %a to i128
374 ; Zero extension from i1 from memory.
375 define i128 @f28(ptr %ptr) {
378 ; CHECK-NEXT: vgbm %v0, 0
379 ; CHECK-NEXT: vleb %v0, 0(%r3), 15
380 ; CHECK-NEXT: vst %v0, 0(%r2), 3
381 ; CHECK-NEXT: br %r14
382 %a = load i1, ptr %ptr
383 %res = zext i1 %a to i128
388 define i1 @f29(i128 %a) {
391 ; CHECK-NEXT: vl %v0, 0(%r2), 3
392 ; CHECK-NEXT: vaq %v0, %v0, %v0
393 ; CHECK-NEXT: vlgvf %r2, %v0, 3
394 ; CHECK-NEXT: # kill: def $r2l killed $r2l killed $r2d
395 ; CHECK-NEXT: br %r14
396 %op = add i128 %a, %a
397 %res = trunc i128 %op to i1
401 ; Truncation to i1 in memory.
402 define void @f30(ptr %ptr, i128 %a) {
405 ; CHECK-NEXT: vl %v0, 0(%r3), 3
406 ; CHECK-NEXT: larl %r1, .LCPI29_0
407 ; CHECK-NEXT: vl %v1, 0(%r1), 3
408 ; CHECK-NEXT: vaq %v0, %v0, %v0
409 ; CHECK-NEXT: vn %v0, %v0, %v1
410 ; CHECK-NEXT: vsteb %v0, 0(%r2), 15
411 ; CHECK-NEXT: br %r14
412 %op = add i128 %a, %a
413 %res = trunc i128 %op to i1
414 store i1 %res, ptr %ptr