xref: /llvm-project/llvm/test/CodeGen/SystemZ/vec-rot-01.ll (revision c61eb440059d6e9c18e6f8404e06bf125aa942c9)
1*c61eb440SUlrich Weigand; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2*c61eb440SUlrich Weigand; Test vector rotate left instructions with vector rotate amount.
3*c61eb440SUlrich Weigand;
4*c61eb440SUlrich Weigand; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5*c61eb440SUlrich Weigand
6*c61eb440SUlrich Weiganddeclare <16 x i8> @llvm.fshl.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
7*c61eb440SUlrich Weiganddeclare <8 x i16> @llvm.fshl.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
8*c61eb440SUlrich Weiganddeclare <4 x i32> @llvm.fshl.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
9*c61eb440SUlrich Weiganddeclare <2 x i64> @llvm.fshl.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
10*c61eb440SUlrich Weigand
11*c61eb440SUlrich Weigand; Test a v16i8 rotate left.
12*c61eb440SUlrich Weiganddefine <16 x i8> @f1(<16 x i8> %dummy, <16 x i8> %val, <16 x i8> %amt) {
13*c61eb440SUlrich Weigand; CHECK-LABEL: f1:
14*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
15*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvb %v24, %v26, %v28
16*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
17*c61eb440SUlrich Weigand
18*c61eb440SUlrich Weigand  %inv = sub <16 x i8> <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8,
19*c61eb440SUlrich Weigand                        i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>, %amt
20*c61eb440SUlrich Weigand  %parta = shl <16 x i8> %val, %amt
21*c61eb440SUlrich Weigand  %partb = lshr <16 x i8> %val, %inv
22*c61eb440SUlrich Weigand
23*c61eb440SUlrich Weigand  %rotl = or <16 x i8> %parta, %partb
24*c61eb440SUlrich Weigand
25*c61eb440SUlrich Weigand  ret <16 x i8> %rotl
26*c61eb440SUlrich Weigand}
27*c61eb440SUlrich Weigand
28*c61eb440SUlrich Weigand; Test a v16i8 rotate left (matched from fshl).
29*c61eb440SUlrich Weiganddefine <16 x i8> @f2(<16 x i8> %dummy, <16 x i8> %val, <16 x i8> %amt) {
30*c61eb440SUlrich Weigand; CHECK-LABEL: f2:
31*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
32*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvb %v24, %v26, %v28
33*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
34*c61eb440SUlrich Weigand
35*c61eb440SUlrich Weigand  %rotl = tail call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %val, <16 x i8> %val, <16 x i8> %amt)
36*c61eb440SUlrich Weigand
37*c61eb440SUlrich Weigand  ret <16 x i8> %rotl
38*c61eb440SUlrich Weigand}
39*c61eb440SUlrich Weigand
40*c61eb440SUlrich Weigand; Test a v8i16 rotate left.
41*c61eb440SUlrich Weiganddefine <8 x i16> @f3(<8 x i16> %dummy, <8 x i16> %val, <8 x i16> %amt) {
42*c61eb440SUlrich Weigand; CHECK-LABEL: f3:
43*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
44*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvh %v24, %v26, %v28
45*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
46*c61eb440SUlrich Weigand
47*c61eb440SUlrich Weigand  %inv = sub <8 x i16> <i16 16, i16 16, i16 16, i16 16,
48*c61eb440SUlrich Weigand                        i16 16, i16 16, i16 16, i16 16>, %amt
49*c61eb440SUlrich Weigand  %parta = shl <8 x i16> %val, %amt
50*c61eb440SUlrich Weigand  %partb = lshr <8 x i16> %val, %inv
51*c61eb440SUlrich Weigand
52*c61eb440SUlrich Weigand  %rotl = or <8 x i16> %parta, %partb
53*c61eb440SUlrich Weigand
54*c61eb440SUlrich Weigand  ret <8 x i16> %rotl
55*c61eb440SUlrich Weigand}
56*c61eb440SUlrich Weigand
57*c61eb440SUlrich Weigand; Test a v8i16 rotate left (matched from fshl).
58*c61eb440SUlrich Weiganddefine <8 x i16> @f4(<8 x i16> %dummy, <8 x i16> %val, <8 x i16> %amt) {
59*c61eb440SUlrich Weigand; CHECK-LABEL: f4:
60*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
61*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvh %v24, %v26, %v28
62*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
63*c61eb440SUlrich Weigand
64*c61eb440SUlrich Weigand  %rotl = tail call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %val, <8 x i16> %val, <8 x i16> %amt)
65*c61eb440SUlrich Weigand
66*c61eb440SUlrich Weigand  ret <8 x i16> %rotl
67*c61eb440SUlrich Weigand}
68*c61eb440SUlrich Weigand
69*c61eb440SUlrich Weigand; Test a v4i32 rotate left.
70*c61eb440SUlrich Weiganddefine <4 x i32> @f5(<4 x i32> %dummy, <4 x i32> %val, <4 x i32> %amt) {
71*c61eb440SUlrich Weigand; CHECK-LABEL: f5:
72*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
73*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvf %v24, %v26, %v28
74*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
75*c61eb440SUlrich Weigand
76*c61eb440SUlrich Weigand  %inv = sub <4 x i32> <i32 32, i32 32, i32 32, i32 32>, %amt
77*c61eb440SUlrich Weigand  %parta = shl <4 x i32> %val, %amt
78*c61eb440SUlrich Weigand  %partb = lshr <4 x i32> %val, %inv
79*c61eb440SUlrich Weigand
80*c61eb440SUlrich Weigand  %rotl = or <4 x i32> %parta, %partb
81*c61eb440SUlrich Weigand
82*c61eb440SUlrich Weigand  ret <4 x i32> %rotl
83*c61eb440SUlrich Weigand}
84*c61eb440SUlrich Weigand
85*c61eb440SUlrich Weigand; Test a v4i32 rotate left (matched from fshl).
86*c61eb440SUlrich Weiganddefine <4 x i32> @f6(<4 x i32> %dummy, <4 x i32> %val, <4 x i32> %amt) {
87*c61eb440SUlrich Weigand; CHECK-LABEL: f6:
88*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
89*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvf %v24, %v26, %v28
90*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
91*c61eb440SUlrich Weigand
92*c61eb440SUlrich Weigand  %rotl = tail call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %val, <4 x i32> %val, <4 x i32> %amt)
93*c61eb440SUlrich Weigand
94*c61eb440SUlrich Weigand  ret <4 x i32> %rotl
95*c61eb440SUlrich Weigand}
96*c61eb440SUlrich Weigand
97*c61eb440SUlrich Weigand; Test a v2i64 rotate left.
98*c61eb440SUlrich Weiganddefine <2 x i64> @f7(<2 x i64> %dummy, <2 x i64> %val, <2 x i64> %amt) {
99*c61eb440SUlrich Weigand; CHECK-LABEL: f7:
100*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
101*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvg %v24, %v26, %v28
102*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
103*c61eb440SUlrich Weigand
104*c61eb440SUlrich Weigand  %inv = sub <2 x i64> <i64 64, i64 64>, %amt
105*c61eb440SUlrich Weigand  %parta = shl <2 x i64> %val, %amt
106*c61eb440SUlrich Weigand  %partb = lshr <2 x i64> %val, %inv
107*c61eb440SUlrich Weigand
108*c61eb440SUlrich Weigand  %rotl = or <2 x i64> %parta, %partb
109*c61eb440SUlrich Weigand
110*c61eb440SUlrich Weigand  ret <2 x i64> %rotl
111*c61eb440SUlrich Weigand}
112*c61eb440SUlrich Weigand
113*c61eb440SUlrich Weigand; Test a v2i64 rotate left (matched from fshl).
114*c61eb440SUlrich Weiganddefine <2 x i64> @f8(<2 x i64> %dummy, <2 x i64> %val, <2 x i64> %amt) {
115*c61eb440SUlrich Weigand; CHECK-LABEL: f8:
116*c61eb440SUlrich Weigand; CHECK:       # %bb.0:
117*c61eb440SUlrich Weigand; CHECK-NEXT:    verllvg %v24, %v26, %v28
118*c61eb440SUlrich Weigand; CHECK-NEXT:    br %r14
119*c61eb440SUlrich Weigand
120*c61eb440SUlrich Weigand  %rotl = tail call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %val, <2 x i64> %val, <2 x i64> %amt)
121*c61eb440SUlrich Weigand
122*c61eb440SUlrich Weigand  ret <2 x i64> %rotl
123*c61eb440SUlrich Weigand}
124