1 ; Test loads of byte-swapped vector elements.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 | FileCheck %s
5 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
6 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
7 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
10 define <8 x i16> @f1(<8 x i16> *%ptr) {
12 ; CHECK: vlbrh %v24, 0(%r2)
14 %load = load <8 x i16>, <8 x i16> *%ptr
15 %ret = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %load)
20 define <4 x i32> @f2(<4 x i32> *%ptr) {
22 ; CHECK: vlbrf %v24, 0(%r2)
24 %load = load <4 x i32>, <4 x i32> *%ptr
25 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)
30 define <2 x i64> @f3(<2 x i64> *%ptr) {
32 ; CHECK: vlbrg %v24, 0(%r2)
34 %load = load <2 x i64>, <2 x i64> *%ptr
35 %ret = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %load)
39 ; Test the highest aligned in-range offset.
40 define <4 x i32> @f4(<4 x i32> *%base) {
42 ; CHECK: vlbrf %v24, 4080(%r2)
44 %ptr = getelementptr <4 x i32>, <4 x i32> *%base, i64 255
45 %load = load <4 x i32>, <4 x i32> *%ptr
46 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)
50 ; Test the highest unaligned in-range offset.
51 define <4 x i32> @f5(i8 *%base) {
53 ; CHECK: vlbrf %v24, 4095(%r2)
55 %addr = getelementptr i8, i8 *%base, i64 4095
56 %ptr = bitcast i8 *%addr to <4 x i32> *
57 %load = load <4 x i32>, <4 x i32> *%ptr
58 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)
62 ; Test the next offset up, which requires separate address logic,
63 define <4 x i32> @f6(<4 x i32> *%base) {
65 ; CHECK: aghi %r2, 4096
66 ; CHECK: vlbrf %v24, 0(%r2)
68 %ptr = getelementptr <4 x i32>, <4 x i32> *%base, i64 256
69 %load = load <4 x i32>, <4 x i32> *%ptr
70 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)
74 ; Test negative offsets, which also require separate address logic,
75 define <4 x i32> @f7(<4 x i32> *%base) {
77 ; CHECK: aghi %r2, -16
78 ; CHECK: vlbrf %v24, 0(%r2)
80 %ptr = getelementptr <4 x i32>, <4 x i32> *%base, i64 -1
81 %load = load <4 x i32>, <4 x i32> *%ptr
82 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)
86 ; Check that indexes are allowed.
87 define <4 x i32> @f8(i8 *%base, i64 %index) {
89 ; CHECK: vlbrf %v24, 0(%r3,%r2)
91 %addr = getelementptr i8, i8 *%base, i64 %index
92 %ptr = bitcast i8 *%addr to <4 x i32> *
93 %load = load <4 x i32>, <4 x i32> *%ptr
94 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %load)