1; Test vector replicates, v8i16 version.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
4
5; Test a byte-granularity replicate with the lowest useful value.
6define <8 x i16> @f1() {
7; CHECK-LABEL: f1:
8; CHECK: vrepib %v24, 1
9; CHECK: br %r14
10  ret <8 x i16> <i16 257, i16 257, i16 257, i16 257,
11                 i16 257, i16 257, i16 257, i16 257>
12}
13
14; Test a byte-granularity replicate with an arbitrary value.
15define <8 x i16> @f2() {
16; CHECK-LABEL: f2:
17; CHECK: vrepib %v24, -55
18; CHECK: br %r14
19  ret <8 x i16> <i16 51657, i16 51657, i16 51657, i16 51657,
20                 i16 51657, i16 51657, i16 51657, i16 51657>
21}
22
23; Test a byte-granularity replicate with the highest useful value.
24define <8 x i16> @f3() {
25; CHECK-LABEL: f3:
26; CHECK: vrepib %v24, -2
27; CHECK: br %r14
28  ret <8 x i16> <i16 -258, i16 -258, i16 -258, i16 -258,
29                 i16 -258, i16 -258, i16 -258, i16 -258>
30}
31
32; Test a halfword-granularity replicate with the lowest useful value.
33define <8 x i16> @f4() {
34; CHECK-LABEL: f4:
35; CHECK: vrepih %v24, 1
36; CHECK: br %r14
37  ret <8 x i16> <i16 1, i16 1, i16 1, i16 1,
38                 i16 1, i16 1, i16 1, i16 1>
39}
40
41; Test a halfword-granularity replicate with an arbitrary value.
42define <8 x i16> @f5() {
43; CHECK-LABEL: f5:
44; CHECK: vrepih %v24, 25650
45; CHECK: br %r14
46  ret <8 x i16> <i16 25650, i16 25650, i16 25650, i16 25650,
47                 i16 25650, i16 25650, i16 25650, i16 25650>
48}
49
50; Test a halfword-granularity replicate with the highest useful value.
51define <8 x i16> @f6() {
52; CHECK-LABEL: f6:
53; CHECK: vrepih %v24, -2
54; CHECK: br %r14
55  ret <8 x i16> <i16 65534, i16 65534, i16 65534, i16 65534,
56                 i16 65534, i16 65534, i16 65534, i16 65534>
57}
58
59; Test a word-granularity replicate with the lowest useful positive value.
60define <8 x i16> @f7() {
61; CHECK-LABEL: f7:
62; CHECK: vrepif %v24, 1
63; CHECK: br %r14
64  ret <8 x i16> <i16 0, i16 1, i16 0, i16 1,
65                 i16 0, i16 1, i16 0, i16 1>
66}
67
68; Test a word-granularity replicate with the highest in-range value.
69define <8 x i16> @f8() {
70; CHECK-LABEL: f8:
71; CHECK: vrepif %v24, 32767
72; CHECK: br %r14
73  ret <8 x i16> <i16 0, i16 32767, i16 0, i16 32767,
74                 i16 0, i16 32767, i16 0, i16 32767>
75}
76
77; Test a word-granularity replicate with the next highest value.
78; This cannot use VREPIF.
79define <8 x i16> @f9() {
80; CHECK-LABEL: f9:
81; CHECK-NOT: vrepif
82; CHECK: br %r14
83  ret <8 x i16> <i16 0, i16 32768, i16 0, i16 32768,
84                 i16 0, i16 32768, i16 0, i16 32768>
85}
86
87; Test a word-granularity replicate with the lowest in-range value.
88define <8 x i16> @f10() {
89; CHECK-LABEL: f10:
90; CHECK: vrepif %v24, -32768
91; CHECK: br %r14
92  ret <8 x i16> <i16 -1, i16 -32768, i16 -1, i16 -32768,
93                 i16 -1, i16 -32768, i16 -1, i16 -32768>
94}
95
96; Test a word-granularity replicate with the next lowest value.
97; This cannot use VREPIF.
98define <8 x i16> @f11() {
99; CHECK-LABEL: f11:
100; CHECK-NOT: vrepif
101; CHECK: br %r14
102  ret <8 x i16> <i16 -1, i16 -32769, i16 -1, i16 -32769,
103                 i16 -1, i16 -32769, i16 -1, i16 -32769>
104}
105
106; Test a word-granularity replicate with the highest useful negative value.
107define <8 x i16> @f12() {
108; CHECK-LABEL: f12:
109; CHECK: vrepif %v24, -2
110; CHECK: br %r14
111  ret <8 x i16> <i16 -1, i16 -2, i16 -1, i16 -2,
112                 i16 -1, i16 -2, i16 -1, i16 -2>
113}
114
115; Test a doubleword-granularity replicate with the lowest useful positive
116; value.
117define <8 x i16> @f13() {
118; CHECK-LABEL: f13:
119; CHECK: vrepig %v24, 1
120; CHECK: br %r14
121  ret <8 x i16> <i16 0, i16 0, i16 0, i16 1,
122                 i16 0, i16 0, i16 0, i16 1>
123}
124
125; Test a doubleword-granularity replicate with the highest in-range value.
126define <8 x i16> @f14() {
127; CHECK-LABEL: f14:
128; CHECK: vrepig %v24, 32767
129; CHECK: br %r14
130  ret <8 x i16> <i16 0, i16 0, i16 0, i16 32767,
131                 i16 0, i16 0, i16 0, i16 32767>
132}
133
134; Test a doubleword-granularity replicate with the next highest value.
135; This cannot use VREPIG.
136define <8 x i16> @f15() {
137; CHECK-LABEL: f15:
138; CHECK-NOT: vrepig
139; CHECK: br %r14
140  ret <8 x i16> <i16 0, i16 0, i16 0, i16 32768,
141                 i16 0, i16 0, i16 0, i16 32768>
142}
143
144; Test a doubleword-granularity replicate with the lowest in-range value.
145define <8 x i16> @f16() {
146; CHECK-LABEL: f16:
147; CHECK: vrepig %v24, -32768
148; CHECK: br %r14
149  ret <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -32768,
150                 i16 -1, i16 -1, i16 -1, i16 -32768>
151}
152
153; Test a doubleword-granularity replicate with the next lowest value.
154; This cannot use VREPIG.
155define <8 x i16> @f17() {
156; CHECK-LABEL: f17:
157; CHECK-NOT: vrepig
158; CHECK: br %r14
159  ret <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -32769,
160                 i16 -1, i16 -1, i16 -1, i16 -32769>
161}
162
163; Test a doubleword-granularity replicate with the highest useful negative
164; value.
165define <8 x i16> @f18() {
166; CHECK-LABEL: f18:
167; CHECK: vrepig %v24, -2
168; CHECK: br %r14
169  ret <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -2,
170                 i16 -1, i16 -1, i16 -1, i16 -2>
171}
172
173; Repeat f14 with undefs optimistically treated as 0.
174define <8 x i16> @f19() {
175; CHECK-LABEL: f19:
176; CHECK: vrepig %v24, 32767
177; CHECK: br %r14
178  ret <8 x i16> <i16 0, i16 undef, i16 0, i16 32767,
179                 i16 undef, i16 0, i16 undef, i16 32767>
180}
181
182; Repeat f18 with undefs optimistically treated as -1.
183define <8 x i16> @f20() {
184; CHECK-LABEL: f20:
185; CHECK: vrepig %v24, -2
186; CHECK: br %r14
187  ret <8 x i16> <i16 -1, i16 -1, i16 undef, i16 -2,
188                 i16 undef, i16 undef, i16 -1, i16 -2>
189}
190