1; Test vector insertions of byte-swapped memory values into 0. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 | FileCheck %s 4 5declare i16 @llvm.bswap.i16(i16) 6declare i32 @llvm.bswap.i32(i32) 7declare i64 @llvm.bswap.i64(i64) 8declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>) 9declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) 10declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>) 11 12; Test VLLEBRZH. 13define <8 x i16> @f1(i16 *%ptr) { 14; CHECK-LABEL: f1: 15; CHECK: vllebrzh %v24, 0(%r2) 16; CHECK: br %r14 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 20 ret <8 x i16> %ret 21} 22 23; Test VLLEBRZH using a vector bswap. 24define <8 x i16> @f2(i16 *%ptr) { 25; CHECK-LABEL: f2: 26; CHECK: vllebrzh %v24, 0(%r2) 27; CHECK: br %r14 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) 31 ret <8 x i16> %ret 32} 33 34; Test VLLEBRZF. 35define <4 x i32> @f3(i32 *%ptr) { 36; CHECK-LABEL: f3: 37; CHECK: vllebrzf %v24, 0(%r2) 38; CHECK: br %r14 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 42 ret <4 x i32> %ret 43} 44 45; Test VLLEBRZF using a vector bswap. 46define <4 x i32> @f4(i32 *%ptr) { 47; CHECK-LABEL: f4: 48; CHECK: vllebrzf %v24, 0(%r2) 49; CHECK: br %r14 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) 53 ret <4 x i32> %ret 54} 55 56; Test VLLEBRZG. 57define <2 x i64> @f5(i64 *%ptr) { 58; CHECK-LABEL: f5: 59; CHECK: vllebrzg %v24, 0(%r2) 60; CHECK: br %r14 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 64 ret <2 x i64> %ret 65} 66 67; Test VLLEBRZG using a vector bswap. 68define <2 x i64> @f6(i64 *%ptr) { 69; CHECK-LABEL: f6: 70; CHECK: vllebrzg %v24, 0(%r2) 71; CHECK: br %r14 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) 75 ret <2 x i64> %ret 76} 77 78; Test VLLEBRZE. 79define <4 x i32> @f7(i32 *%ptr) { 80; CHECK-LABEL: f7: 81; CHECK: vllebrze %v24, 0(%r2) 82; CHECK: br %r14 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 86 ret <4 x i32> %ret 87} 88 89; Test VLLEBRZE using a vector bswap. 90define <4 x i32> @f8(i32 *%ptr) { 91; CHECK-LABEL: f8: 92; CHECK: vllebrze %v24, 0(%r2) 93; CHECK: br %r14 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) 97 ret <4 x i32> %ret 98} 99 100; Test VLLEBRZH with the highest in-range offset. 101define <8 x i16> @f9(i16 *%base) { 102; CHECK-LABEL: f9: 103; CHECK: vllebrzh %v24, 4094(%r2) 104; CHECK: br %r14 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 109 ret <8 x i16> %ret 110} 111 112; Test VLLEBRZH with the next highest offset. 113define <8 x i16> @f10(i16 *%base) { 114; CHECK-LABEL: f10: 115; CHECK-NOT: vllebrzh %v24, 4096(%r2) 116; CHECK: br %r14 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 121 ret <8 x i16> %ret 122} 123 124; Test that VLLEBRZH allows an index. 125define <8 x i16> @f11(i16 *%base, i64 %index) { 126; CHECK-LABEL: f11: 127; CHECK: sllg [[REG:%r[1-5]]], %r3, 1 128; CHECK: vllebrzh %v24, 0([[REG]],%r2) 129; CHECK: br %r14 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 134 ret <8 x i16> %ret 135} 136 137