1 ; Test vector insertions of byte-swapped memory values into 0.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=arch13 | FileCheck %s
5 declare i16 @llvm.bswap.i16(i16)
6 declare i32 @llvm.bswap.i32(i32)
7 declare i64 @llvm.bswap.i64(i64)
8 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
9 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
10 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
13 define <8 x i16> @f1(i16 *%ptr) {
15 ; CHECK: vllebrzh %v24, 0(%r2)
17 %val = load i16, i16 *%ptr
18 %swap = call i16 @llvm.bswap.i16(i16 %val)
19 %ret = insertelement <8 x i16> zeroinitializer, i16 %swap, i32 3
23 ; Test VLLEBRZH using a vector bswap.
24 define <8 x i16> @f2(i16 *%ptr) {
26 ; CHECK: vllebrzh %v24, 0(%r2)
28 %val = load i16, i16 *%ptr
29 %insert = insertelement <8 x i16> zeroinitializer, i16 %val, i32 3
30 %ret = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %insert)
35 define <4 x i32> @f3(i32 *%ptr) {
37 ; CHECK: vllebrzf %v24, 0(%r2)
39 %val = load i32, i32 *%ptr
40 %swap = call i32 @llvm.bswap.i32(i32 %val)
41 %ret = insertelement <4 x i32> zeroinitializer, i32 %swap, i32 1
45 ; Test VLLEBRZF using a vector bswap.
46 define <4 x i32> @f4(i32 *%ptr) {
48 ; CHECK: vllebrzf %v24, 0(%r2)
50 %val = load i32, i32 *%ptr
51 %insert = insertelement <4 x i32> zeroinitializer, i32 %val, i32 1
52 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %insert)
57 define <2 x i64> @f5(i64 *%ptr) {
59 ; CHECK: vllebrzg %v24, 0(%r2)
61 %val = load i64, i64 *%ptr
62 %swap = call i64 @llvm.bswap.i64(i64 %val)
63 %ret = insertelement <2 x i64> zeroinitializer, i64 %swap, i32 0
67 ; Test VLLEBRZG using a vector bswap.
68 define <2 x i64> @f6(i64 *%ptr) {
70 ; CHECK: vllebrzg %v24, 0(%r2)
72 %val = load i64, i64 *%ptr
73 %insert = insertelement <2 x i64> zeroinitializer, i64 %val, i32 0
74 %ret = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %insert)
79 define <4 x i32> @f7(i32 *%ptr) {
81 ; CHECK: vllebrze %v24, 0(%r2)
83 %val = load i32, i32 *%ptr
84 %swap = call i32 @llvm.bswap.i32(i32 %val)
85 %ret = insertelement <4 x i32> zeroinitializer, i32 %swap, i32 0
89 ; Test VLLEBRZE using a vector bswap.
90 define <4 x i32> @f8(i32 *%ptr) {
92 ; CHECK: vllebrze %v24, 0(%r2)
94 %val = load i32, i32 *%ptr
95 %insert = insertelement <4 x i32> zeroinitializer, i32 %val, i32 0
96 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %insert)
100 ; Test VLLEBRZH with the highest in-range offset.
101 define <8 x i16> @f9(i16 *%base) {
103 ; CHECK: vllebrzh %v24, 4094(%r2)
105 %ptr = getelementptr i16, i16 *%base, i64 2047
106 %val = load i16, i16 *%ptr
107 %swap = call i16 @llvm.bswap.i16(i16 %val)
108 %ret = insertelement <8 x i16> zeroinitializer, i16 %swap, i32 3
112 ; Test VLLEBRZH with the next highest offset.
113 define <8 x i16> @f10(i16 *%base) {
115 ; CHECK-NOT: vllebrzh %v24, 4096(%r2)
117 %ptr = getelementptr i16, i16 *%base, i64 2048
118 %val = load i16, i16 *%ptr
119 %swap = call i16 @llvm.bswap.i16(i16 %val)
120 %ret = insertelement <8 x i16> zeroinitializer, i16 %swap, i32 3
124 ; Test that VLLEBRZH allows an index.
125 define <8 x i16> @f11(i16 *%base, i64 %index) {
127 ; CHECK: sllg [[REG:%r[1-5]]], %r3, 1
128 ; CHECK: vllebrzh %v24, 0([[REG]],%r2)
130 %ptr = getelementptr i16, i16 *%base, i64 %index
131 %val = load i16, i16 *%ptr
132 %swap = call i16 @llvm.bswap.i16(i16 %val)
133 %ret = insertelement <8 x i16> zeroinitializer, i16 %swap, i32 3