1; Test vector arithmetic shift right with scalar shift amount.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
4
5; Test a v16i8 shift by a variable.
6define <16 x i8> @f1(<16 x i8> %dummy, <16 x i8> %val1, i32 %shift) {
7; CHECK-LABEL: f1:
8; CHECK: vesrab %v24, %v26, 0(%r2)
9; CHECK: br %r14
10  %truncshift = trunc i32 %shift to i8
11  %shiftvec = insertelement <16 x i8> undef, i8 %truncshift, i32 0
12  %val2 = shufflevector <16 x i8> %shiftvec, <16 x i8> undef,
13                        <16 x i32> zeroinitializer
14  %ret = ashr <16 x i8> %val1, %val2
15  ret <16 x i8> %ret
16}
17
18; Test a v16i8 shift by the lowest useful constant.
19define <16 x i8> @f2(<16 x i8> %dummy, <16 x i8> %val) {
20; CHECK-LABEL: f2:
21; CHECK: vesrab %v24, %v26, 1
22; CHECK: br %r14
23  %ret = ashr <16 x i8> %val, <i8 1, i8 1, i8 1, i8 1,
24                               i8 1, i8 1, i8 1, i8 1,
25                               i8 1, i8 1, i8 1, i8 1,
26                               i8 1, i8 1, i8 1, i8 1>
27  ret <16 x i8> %ret
28}
29
30; Test a v16i8 shift by the highest useful constant.
31define <16 x i8> @f3(<16 x i8> %dummy, <16 x i8> %val) {
32; CHECK-LABEL: f3:
33; CHECK: vesrab %v24, %v26, 7
34; CHECK: br %r14
35  %ret = ashr <16 x i8> %val, <i8 7, i8 7, i8 7, i8 7,
36                               i8 7, i8 7, i8 7, i8 7,
37                               i8 7, i8 7, i8 7, i8 7,
38                               i8 7, i8 7, i8 7, i8 7>
39  ret <16 x i8> %ret
40}
41
42; Test a v8i16 shift by a variable.
43define <8 x i16> @f4(<8 x i16> %dummy, <8 x i16> %val1, i32 %shift) {
44; CHECK-LABEL: f4:
45; CHECK: vesrah %v24, %v26, 0(%r2)
46; CHECK: br %r14
47  %truncshift = trunc i32 %shift to i16
48  %shiftvec = insertelement <8 x i16> undef, i16 %truncshift, i32 0
49  %val2 = shufflevector <8 x i16> %shiftvec, <8 x i16> undef,
50                        <8 x i32> zeroinitializer
51  %ret = ashr <8 x i16> %val1, %val2
52  ret <8 x i16> %ret
53}
54
55; Test a v8i16 shift by the lowest useful constant.
56define <8 x i16> @f5(<8 x i16> %dummy, <8 x i16> %val) {
57; CHECK-LABEL: f5:
58; CHECK: vesrah %v24, %v26, 1
59; CHECK: br %r14
60  %ret = ashr <8 x i16> %val, <i16 1, i16 1, i16 1, i16 1,
61                               i16 1, i16 1, i16 1, i16 1>
62  ret <8 x i16> %ret
63}
64
65; Test a v8i16 shift by the highest useful constant.
66define <8 x i16> @f6(<8 x i16> %dummy, <8 x i16> %val) {
67; CHECK-LABEL: f6:
68; CHECK: vesrah %v24, %v26, 15
69; CHECK: br %r14
70  %ret = ashr <8 x i16> %val, <i16 15, i16 15, i16 15, i16 15,
71                               i16 15, i16 15, i16 15, i16 15>
72  ret <8 x i16> %ret
73}
74
75; Test a v4i32 shift by a variable.
76define <4 x i32> @f7(<4 x i32> %dummy, <4 x i32> %val1, i32 %shift) {
77; CHECK-LABEL: f7:
78; CHECK: vesraf %v24, %v26, 0(%r2)
79; CHECK: br %r14
80  %shiftvec = insertelement <4 x i32> undef, i32 %shift, i32 0
81  %val2 = shufflevector <4 x i32> %shiftvec, <4 x i32> undef,
82                        <4 x i32> zeroinitializer
83  %ret = ashr <4 x i32> %val1, %val2
84  ret <4 x i32> %ret
85}
86
87; Test a v4i32 shift by the lowest useful constant.
88define <4 x i32> @f8(<4 x i32> %dummy, <4 x i32> %val) {
89; CHECK-LABEL: f8:
90; CHECK: vesraf %v24, %v26, 1
91; CHECK: br %r14
92  %ret = ashr <4 x i32> %val, <i32 1, i32 1, i32 1, i32 1>
93  ret <4 x i32> %ret
94}
95
96; Test a v4i32 shift by the highest useful constant.
97define <4 x i32> @f9(<4 x i32> %dummy, <4 x i32> %val) {
98; CHECK-LABEL: f9:
99; CHECK: vesraf %v24, %v26, 31
100; CHECK: br %r14
101  %ret = ashr <4 x i32> %val, <i32 31, i32 31, i32 31, i32 31>
102  ret <4 x i32> %ret
103}
104
105; Test a v2i64 shift by a variable.
106define <2 x i64> @f10(<2 x i64> %dummy, <2 x i64> %val1, i32 %shift) {
107; CHECK-LABEL: f10:
108; CHECK: vesrag %v24, %v26, 0(%r2)
109; CHECK: br %r14
110  %extshift = sext i32 %shift to i64
111  %shiftvec = insertelement <2 x i64> undef, i64 %extshift, i32 0
112  %val2 = shufflevector <2 x i64> %shiftvec, <2 x i64> undef,
113                        <2 x i32> zeroinitializer
114  %ret = ashr <2 x i64> %val1, %val2
115  ret <2 x i64> %ret
116}
117
118; Test a v2i64 shift by the lowest useful constant.
119define <2 x i64> @f11(<2 x i64> %dummy, <2 x i64> %val) {
120; CHECK-LABEL: f11:
121; CHECK: vesrag %v24, %v26, 1
122; CHECK: br %r14
123  %ret = ashr <2 x i64> %val, <i64 1, i64 1>
124  ret <2 x i64> %ret
125}
126
127; Test a v2i64 shift by the highest useful constant.
128define <2 x i64> @f12(<2 x i64> %dummy, <2 x i64> %val) {
129; CHECK-LABEL: f12:
130; CHECK: vesrag %v24, %v26, 63
131; CHECK: br %r14
132  %ret = ashr <2 x i64> %val, <i64 63, i64 63>
133  ret <2 x i64> %ret
134}
135