1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test vector rotate left instructions with scalar rotate amount.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
6 declare <16 x i8> @llvm.fshl.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
7 declare <8 x i16> @llvm.fshl.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
8 declare <4 x i32> @llvm.fshl.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
9 declare <2 x i64> @llvm.fshl.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
11 ; Test a v16i8 rotate left.
12 define <16 x i8> @f1(<16 x i8> %dummy, <16 x i8> %val, i32 %scalar) {
15 ; CHECK-NEXT: verllb %v24, %v26, 0(%r2)
18 %scalar_tmp = trunc i32 %scalar to i8
19 %tmp = insertelement <16 x i8> undef, i8 %scalar_tmp, i32 0
20 %amt = shufflevector <16 x i8> %tmp, <16 x i8> undef,
21 <16 x i32> zeroinitializer
23 %inv = sub <16 x i8> <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8,
24 i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>, %amt
25 %parta = shl <16 x i8> %val, %amt
26 %partb = lshr <16 x i8> %val, %inv
28 %rotl = or <16 x i8> %parta, %partb
33 ; Test a v16i8 rotate left (matched from fshl).
34 define <16 x i8> @f2(<16 x i8> %dummy, <16 x i8> %val, i32 %scalar) {
37 ; CHECK-NEXT: verllb %v24, %v26, 0(%r2)
40 %scalar_tmp = trunc i32 %scalar to i8
41 %tmp = insertelement <16 x i8> undef, i8 %scalar_tmp, i32 0
42 %amt = shufflevector <16 x i8> %tmp, <16 x i8> undef,
43 <16 x i32> zeroinitializer
45 %rotl = tail call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %val, <16 x i8> %val, <16 x i8> %amt)
50 ; Test a v8i16 rotate left.
51 define <8 x i16> @f3(<8 x i16> %dummy, <8 x i16> %val, i32 %scalar) {
54 ; CHECK-NEXT: verllh %v24, %v26, 0(%r2)
57 %scalar_tmp = trunc i32 %scalar to i16
58 %tmp = insertelement <8 x i16> undef, i16 %scalar_tmp, i32 0
59 %amt = shufflevector <8 x i16> %tmp, <8 x i16> undef,
60 <8 x i32> zeroinitializer
62 %inv = sub <8 x i16> <i16 16, i16 16, i16 16, i16 16,
63 i16 16, i16 16, i16 16, i16 16>, %amt
64 %parta = shl <8 x i16> %val, %amt
65 %partb = lshr <8 x i16> %val, %inv
67 %rotl = or <8 x i16> %parta, %partb
72 ; Test a v8i16 rotate left (matched from fshl).
73 define <8 x i16> @f4(<8 x i16> %dummy, <8 x i16> %val, i32 %scalar) {
76 ; CHECK-NEXT: verllh %v24, %v26, 0(%r2)
79 %scalar_tmp = trunc i32 %scalar to i16
80 %tmp = insertelement <8 x i16> undef, i16 %scalar_tmp, i32 0
81 %amt = shufflevector <8 x i16> %tmp, <8 x i16> undef,
82 <8 x i32> zeroinitializer
84 %rotl = tail call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %val, <8 x i16> %val, <8 x i16> %amt)
89 ; Test a v4i32 rotate left.
90 define <4 x i32> @f5(<4 x i32> %dummy, <4 x i32> %val, i32 %scalar) {
93 ; CHECK-NEXT: verllf %v24, %v26, 0(%r2)
96 %tmp = insertelement <4 x i32> undef, i32 %scalar, i32 0
97 %amt = shufflevector <4 x i32> %tmp, <4 x i32> undef,
98 <4 x i32> zeroinitializer
100 %inv = sub <4 x i32> <i32 32, i32 32, i32 32, i32 32>, %amt
101 %parta = shl <4 x i32> %val, %amt
102 %partb = lshr <4 x i32> %val, %inv
104 %rotl = or <4 x i32> %parta, %partb
109 ; Test a v4i32 rotate left (matched from fshl).
110 define <4 x i32> @f6(<4 x i32> %dummy, <4 x i32> %val, i32 %scalar) {
113 ; CHECK-NEXT: verllf %v24, %v26, 0(%r2)
114 ; CHECK-NEXT: br %r14
116 %tmp = insertelement <4 x i32> undef, i32 %scalar, i32 0
117 %amt = shufflevector <4 x i32> %tmp, <4 x i32> undef,
118 <4 x i32> zeroinitializer
120 %rotl = tail call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %val, <4 x i32> %val, <4 x i32> %amt)
125 ; Test a v2i64 rotate left.
126 define <2 x i64> @f7(<2 x i64> %dummy, <2 x i64> %val, i32 %scalar) {
129 ; CHECK-NEXT: verllg %v24, %v26, 0(%r2)
130 ; CHECK-NEXT: br %r14
132 %scalar_tmp = zext i32 %scalar to i64
133 %tmp = insertelement <2 x i64> undef, i64 %scalar_tmp, i32 0
134 %amt = shufflevector <2 x i64> %tmp, <2 x i64> undef,
135 <2 x i32> zeroinitializer
137 %inv = sub <2 x i64> <i64 64, i64 64>, %amt
138 %parta = shl <2 x i64> %val, %amt
139 %partb = lshr <2 x i64> %val, %inv
141 %rotl = or <2 x i64> %parta, %partb
146 ; Test a v2i64 rotate left (matched from fshl).
147 define <2 x i64> @f8(<2 x i64> %dummy, <2 x i64> %val, i32 %scalar) {
150 ; CHECK-NEXT: verllg %v24, %v26, 0(%r2)
151 ; CHECK-NEXT: br %r14
153 %scalar_tmp = zext i32 %scalar to i64
154 %tmp = insertelement <2 x i64> undef, i64 %scalar_tmp, i32 0
155 %amt = shufflevector <2 x i64> %tmp, <2 x i64> undef,
156 <2 x i32> zeroinitializer
158 %rotl = tail call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %val, <2 x i64> %val, <2 x i64> %amt)
163 ; Test a v2i64 rotate left (matched from fshl).
164 define <2 x i64> @f9(<2 x i64> %dummy, <2 x i64> %val, i64 %scalar) {
167 ; CHECK-NEXT: verllg %v24, %v26, 0(%r2)
168 ; CHECK-NEXT: br %r14
170 %tmp = insertelement <2 x i64> undef, i64 %scalar, i32 0
171 %amt = shufflevector <2 x i64> %tmp, <2 x i64> undef,
172 <2 x i32> zeroinitializer
174 %rotl = tail call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %val, <2 x i64> %val, <2 x i64> %amt)