1; Test vector replicates, v16i8 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 <16 x i8> @f1() {
7; CHECK-LABEL: f1:
8; CHECK: vrepib %v24, 1
9; CHECK: br %r14
10  ret <16 x i8> <i8 1, i8 1, i8 1, i8 1,
11                 i8 1, i8 1, i8 1, i8 1,
12                 i8 1, i8 1, i8 1, i8 1,
13                 i8 1, i8 1, i8 1, i8 1>
14}
15
16; Test a byte-granularity replicate with an arbitrary value.
17define <16 x i8> @f2() {
18; CHECK-LABEL: f2:
19; CHECK: vrepib %v24, -55
20; CHECK: br %r14
21  ret <16 x i8> <i8 201, i8 201, i8 201, i8 201,
22                 i8 201, i8 201, i8 201, i8 201,
23                 i8 201, i8 201, i8 201, i8 201,
24                 i8 201, i8 201, i8 201, i8 201>
25}
26
27; Test a byte-granularity replicate with the highest useful value.
28define <16 x i8> @f3() {
29; CHECK-LABEL: f3:
30; CHECK: vrepib %v24, -2
31; CHECK: br %r14
32  ret <16 x i8> <i8 254, i8 254, i8 254, i8 254,
33                 i8 254, i8 254, i8 254, i8 254,
34                 i8 254, i8 254, i8 254, i8 254,
35                 i8 254, i8 254, i8 254, i8 254>
36}
37
38; Test a halfword-granularity replicate with the lowest useful value.
39define <16 x i8> @f4() {
40; CHECK-LABEL: f4:
41; CHECK: vrepih %v24, 1
42; CHECK: br %r14
43  ret <16 x i8> <i8 0, i8 1, i8 0, i8 1,
44                 i8 0, i8 1, i8 0, i8 1,
45                 i8 0, i8 1, i8 0, i8 1,
46                 i8 0, i8 1, i8 0, i8 1>
47}
48
49; Test a halfword-granularity replicate with an arbitrary value.
50define <16 x i8> @f5() {
51; CHECK-LABEL: f5:
52; CHECK: vrepih %v24, 25650
53; CHECK: br %r14
54  ret <16 x i8> <i8 100, i8 50, i8 100, i8 50,
55                 i8 100, i8 50, i8 100, i8 50,
56                 i8 100, i8 50, i8 100, i8 50,
57                 i8 100, i8 50, i8 100, i8 50>
58}
59
60; Test a halfword-granularity replicate with the highest useful value.
61define <16 x i8> @f6() {
62; CHECK-LABEL: f6:
63; CHECK: vrepih %v24, -2
64; CHECK: br %r14
65  ret <16 x i8> <i8 255, i8 254, i8 255, i8 254,
66                 i8 255, i8 254, i8 255, i8 254,
67                 i8 255, i8 254, i8 255, i8 254,
68                 i8 255, i8 254, i8 255, i8 254>
69}
70
71; Test a word-granularity replicate with the lowest useful positive value.
72define <16 x i8> @f7() {
73; CHECK-LABEL: f7:
74; CHECK: vrepif %v24, 1
75; CHECK: br %r14
76  ret <16 x i8> <i8 0, i8 0, i8 0, i8 1,
77                 i8 0, i8 0, i8 0, i8 1,
78                 i8 0, i8 0, i8 0, i8 1,
79                 i8 0, i8 0, i8 0, i8 1>
80}
81
82; Test a word-granularity replicate with the highest in-range value.
83define <16 x i8> @f8() {
84; CHECK-LABEL: f8:
85; CHECK: vrepif %v24, 32767
86; CHECK: br %r14
87  ret <16 x i8> <i8 0, i8 0, i8 127, i8 255,
88                 i8 0, i8 0, i8 127, i8 255,
89                 i8 0, i8 0, i8 127, i8 255,
90                 i8 0, i8 0, i8 127, i8 255>
91}
92
93; Test a word-granularity replicate with the next highest value.
94; This cannot use VREPIF.
95define <16 x i8> @f9() {
96; CHECK-LABEL: f9:
97; CHECK-NOT: vrepif
98; CHECK: br %r14
99  ret <16 x i8> <i8 0, i8 0, i8 128, i8 0,
100                 i8 0, i8 0, i8 128, i8 0,
101                 i8 0, i8 0, i8 128, i8 0,
102                 i8 0, i8 0, i8 128, i8 0>
103}
104
105; Test a word-granularity replicate with the lowest in-range value.
106define <16 x i8> @f10() {
107; CHECK-LABEL: f10:
108; CHECK: vrepif %v24, -32768
109; CHECK: br %r14
110  ret <16 x i8> <i8 255, i8 255, i8 128, i8 0,
111                 i8 255, i8 255, i8 128, i8 0,
112                 i8 255, i8 255, i8 128, i8 0,
113                 i8 255, i8 255, i8 128, i8 0>
114}
115
116; Test a word-granularity replicate with the next lowest value.
117; This cannot use VREPIF.
118define <16 x i8> @f11() {
119; CHECK-LABEL: f11:
120; CHECK-NOT: vrepif
121; CHECK: br %r14
122  ret <16 x i8> <i8 255, i8 255, i8 127, i8 255,
123                 i8 255, i8 255, i8 127, i8 255,
124                 i8 255, i8 255, i8 127, i8 255,
125                 i8 255, i8 255, i8 127, i8 255>
126}
127
128; Test a word-granularity replicate with the highest useful negative value.
129define <16 x i8> @f12() {
130; CHECK-LABEL: f12:
131; CHECK: vrepif %v24, -2
132; CHECK: br %r14
133  ret <16 x i8> <i8 255, i8 255, i8 255, i8 254,
134                 i8 255, i8 255, i8 255, i8 254,
135                 i8 255, i8 255, i8 255, i8 254,
136                 i8 255, i8 255, i8 255, i8 254>
137}
138
139; Test a doubleword-granularity replicate with the lowest useful positive
140; value.
141define <16 x i8> @f13() {
142; CHECK-LABEL: f13:
143; CHECK: vrepig %v24, 1
144; CHECK: br %r14
145  ret <16 x i8> <i8 0, i8 0, i8 0, i8 0,
146                 i8 0, i8 0, i8 0, i8 1,
147                 i8 0, i8 0, i8 0, i8 0,
148                 i8 0, i8 0, i8 0, i8 1>
149}
150
151; Test a doubleword-granularity replicate with the highest in-range value.
152define <16 x i8> @f14() {
153; CHECK-LABEL: f14:
154; CHECK: vrepig %v24, 32767
155; CHECK: br %r14
156  ret <16 x i8> <i8 0, i8 0, i8 0, i8 0,
157                 i8 0, i8 0, i8 127, i8 255,
158                 i8 0, i8 0, i8 0, i8 0,
159                 i8 0, i8 0, i8 127, i8 255>
160}
161
162; Test a doubleword-granularity replicate with the next highest value.
163; This cannot use VREPIG.
164define <16 x i8> @f15() {
165; CHECK-LABEL: f15:
166; CHECK-NOT: vrepig
167; CHECK: br %r14
168  ret <16 x i8> <i8 0, i8 0, i8 0, i8 0,
169                 i8 0, i8 0, i8 128, i8 0,
170                 i8 0, i8 0, i8 0, i8 0,
171                 i8 0, i8 0, i8 128, i8 0>
172}
173
174; Test a doubleword-granularity replicate with the lowest in-range value.
175define <16 x i8> @f16() {
176; CHECK-LABEL: f16:
177; CHECK: vrepig %v24, -32768
178; CHECK: br %r14
179  ret <16 x i8> <i8 255, i8 255, i8 255, i8 255,
180                 i8 255, i8 255, i8 128, i8 0,
181                 i8 255, i8 255, i8 255, i8 255,
182                 i8 255, i8 255, i8 128, i8 0>
183}
184
185; Test a doubleword-granularity replicate with the next lowest value.
186; This cannot use VREPIG.
187define <16 x i8> @f17() {
188; CHECK-LABEL: f17:
189; CHECK-NOT: vrepig
190; CHECK: br %r14
191  ret <16 x i8> <i8 255, i8 255, i8 255, i8 255,
192                 i8 255, i8 255, i8 127, i8 255,
193                 i8 255, i8 255, i8 255, i8 255,
194                 i8 255, i8 255, i8 127, i8 255>
195}
196
197; Test a doubleword-granularity replicate with the highest useful negative
198; value.
199define <16 x i8> @f18() {
200; CHECK-LABEL: f18:
201; CHECK: vrepig %v24, -2
202; CHECK: br %r14
203  ret <16 x i8> <i8 255, i8 255, i8 255, i8 255,
204                 i8 255, i8 255, i8 255, i8 254,
205                 i8 255, i8 255, i8 255, i8 255,
206                 i8 255, i8 255, i8 255, i8 254>
207}
208
209; Repeat f14 with undefs optimistically treated as 0.
210define <16 x i8> @f19() {
211; CHECK-LABEL: f19:
212; CHECK: vrepig %v24, 32767
213; CHECK: br %r14
214  ret <16 x i8> <i8 0, i8 undef, i8 0, i8 0,
215                 i8 0, i8 0, i8 127, i8 255,
216                 i8 undef, i8 0, i8 undef, i8 0,
217                 i8 0, i8 0, i8 127, i8 255>
218}
219
220; Repeat f18 with undefs optimistically treated as -1.
221define <16 x i8> @f20() {
222; CHECK-LABEL: f20:
223; CHECK: vrepig %v24, -2
224; CHECK: br %r14
225  ret <16 x i8> <i8 undef, i8 255, i8 255, i8 255,
226                 i8 255, i8 255, i8 undef, i8 254,
227                 i8 255, i8 255, i8 255, i8 undef,
228                 i8 255, i8 undef, i8 255, i8 254>
229}
230