1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
3; RUN:     -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
4; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
5; RUN:     -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
6
7define dso_local <4 x i32> @testZero() local_unnamed_addr {
8; CHECK-LABEL: testZero:
9; CHECK:       # %bb.0: # %entry
10; CHECK-NEXT:    xxlxor vs34, vs34, vs34
11; CHECK-NEXT:    blr
12
13entry:
14  ret <4 x i32> zeroinitializer
15}
16
17define dso_local <4 x float> @testZeroF() local_unnamed_addr {
18; CHECK-LABEL: testZeroF:
19; CHECK:       # %bb.0: # %entry
20; CHECK-NEXT:    xxlxor vs34, vs34, vs34
21; CHECK-NEXT:    blr
22
23entry:
24  ret <4 x float> zeroinitializer
25}
26
27define dso_local <4 x i32> @testAllOneS() local_unnamed_addr {
28; CHECK-LABEL: testAllOneS:
29; CHECK:       # %bb.0: # %entry
30; CHECK-NEXT:    xxleqv vs34, vs34, vs34
31; CHECK-NEXT:    blr
32
33entry:
34  ret <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
35}
36
37define dso_local <4 x i32> @test5Bit() local_unnamed_addr {
38; CHECK-LABEL: test5Bit:
39; CHECK:       # %bb.0: # %entry
40; CHECK-NEXT:    vspltisw v2, 7
41; CHECK-NEXT:    blr
42
43entry:
44  ret <4 x i32> <i32 7, i32 7, i32 7, i32 7>
45}
46
47define dso_local <16 x i8> @test1ByteChar() local_unnamed_addr {
48; CHECK-LABEL: test1ByteChar:
49; CHECK:       # %bb.0: # %entry
50; CHECK-NEXT:    xxspltib vs34, 7
51; CHECK-NEXT:    blr
52
53entry:
54  ret <16 x i8> <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
55}
56
57define dso_local <4 x i32> @test1ByteSplatInt() local_unnamed_addr {
58; Here the splat of 171 or 0xABABABAB can be done using a byte splat
59; of 0xAB using xxspltib while avoiding the use of xxspltiw.
60; CHECK-LABEL: test1ByteSplatInt:
61; CHECK:       # %bb.0: # %entry
62; CHECK-NEXT:    xxspltib vs34, 171
63; CHECK-NEXT:    blr
64
65entry:
66  ret <4 x i32> <i32 -1414812757, i32 -1414812757, i32 -1414812757, i32 -1414812757>
67}
68
69define dso_local <4 x i32> @test5Bit2Ins() local_unnamed_addr {
70; Splats within the range [-32,31] can be done using two vsplti[bhw]
71; instructions, but we prefer the xxspltiw instruction to them.
72; CHECK-LABEL: test5Bit2Ins:
73; CHECK:       # %bb.0: # %entry
74; CHECK-NEXT:    xxspltiw vs34, 16
75; CHECK-NEXT:    blr
76
77entry:
78  ret <4 x i32> <i32 16, i32 16, i32 16, i32 16>
79}
80
81define dso_local <4 x float> @testFloatNegZero() local_unnamed_addr {
82; 0.0f is not the same as -0.0f. We try to splat -0.0f
83; CHECK-LABEL: testFloatNegZero:
84; CHECK:       # %bb.0: # %entry
85; CHECK-NEXT:    xxspltiw vs34, -2147483648
86; CHECK-NEXT:    blr
87
88entry:
89  ret <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>
90}
91
92define dso_local <4 x float> @testFloat() local_unnamed_addr {
93; CHECK-LABEL: testFloat:
94; CHECK:       # %bb.0: # %entry
95; CHECK-NEXT:    xxspltiw vs34, 1135323709
96; CHECK-NEXT:    blr
97
98entry:
99  ret <4 x float> <float 0x40757547A0000000, float 0x40757547A0000000, float 0x40757547A0000000, float 0x40757547A0000000>
100}
101
102define dso_local <4 x float> @testIntToFloat() local_unnamed_addr {
103; CHECK-LABEL: testIntToFloat:
104; CHECK:       # %bb.0: # %entry
105; CHECK-NEXT:    xxspltiw vs34, 1135312896
106; CHECK-NEXT:    blr
107
108entry:
109  ret <4 x float> <float 3.430000e+02, float 3.430000e+02, float 3.430000e+02, float 3.430000e+02>
110}
111
112define dso_local <4 x i32> @testUndefInt() local_unnamed_addr {
113; CHECK-LABEL: testUndefInt:
114; CHECK:       # %bb.0: # %entry
115; CHECK-NEXT:    xxspltiw vs34, 18
116; CHECK-NEXT:    blr
117
118entry:
119  ret <4 x i32> <i32 18, i32 undef, i32 undef, i32 18>
120}
121
122define dso_local <4 x float> @testUndefIntToFloat() local_unnamed_addr {
123; CHECK-LABEL: testUndefIntToFloat:
124; CHECK:       # %bb.0: # %entry
125; CHECK-NEXT:    xxspltiw vs34, 1135312896
126; CHECK-NEXT:    blr
127
128entry:
129  ret <4 x float> <float 3.430000e+02, float undef, float undef, float 3.430000e+02>
130}
131
132define dso_local <2 x i64> @testPseudo8Byte() local_unnamed_addr {
133; CHECK-LABEL: testPseudo8Byte:
134; CHECK:       # %bb.0: # %entry
135; CHECK-NEXT:    xxspltiw vs34, -1430532899
136; CHECK-NEXT:    blr
137
138entry:
139  ret <2 x i64> <i64 -6144092014192636707, i64 -6144092014192636707>
140}
141
142define dso_local <8 x i16> @test2Byte() local_unnamed_addr {
143; CHECK-LABEL: test2Byte:
144; CHECK:       # %bb.0: # %entry
145; CHECK-NEXT:    xxspltiw vs34, 1179666
146; CHECK-NEXT:    blr
147
148entry:
149  ret <8 x i16> <i16 18, i16 18, i16 18, i16 18, i16 18, i16 18, i16 18, i16 18>
150}
151
152define dso_local <8 x i16> @test2ByteUndef() local_unnamed_addr {
153; CHECK-LABEL: test2ByteUndef:
154; CHECK:       # %bb.0: # %entry
155; CHECK-NEXT:    xxspltiw vs34, 1179666
156; CHECK-NEXT:    blr
157
158entry:
159  ret <8 x i16> <i16 18, i16 undef, i16 18, i16 18, i16 18, i16 undef, i16 18, i16 18>
160}
161
162define dso_local <2 x double> @testFloatToDouble() local_unnamed_addr {
163; CHECK-LABEL: testFloatToDouble:
164; CHECK:       # %bb.0: # %entry
165; CHECK-NEXT:    xxspltidp vs34, 1135290941
166; CHECK-NEXT:    blr
167
168entry:
169  ret <2 x double> <double 0x40756547A0000000, double 0x40756547A0000000>
170}
171
172define dso_local <2 x double> @testDoubleLower4ByteZero() local_unnamed_addr {
173; The expanded double will have 0 in the last 32 bits. Imprecise handling of
174; return value of data structures like APInt, returned when calling getZextValue
175; , like saving the return value into an unsigned instead of uint64_t may cause
176; this test to fail.
177; CHECK-LABEL: testDoubleLower4ByteZero:
178; CHECK:       # %bb.0: # %entry
179; CHECK-NEXT:    xxspltidp vs34, 1093664768
180; CHECK-NEXT:    blr
181
182entry:
183  ret <2 x double> <double 1.100000e+01, double 1.100000e+01>
184}
185
186define dso_local <2 x double> @testDoubleToDoubleZero() local_unnamed_addr {
187; Should be using canonicalized form to splat zero and use shorter instructions
188; than xxspltidp.
189; CHECK-LABEL: testDoubleToDoubleZero:
190; CHECK:       # %bb.0: # %entry
191; CHECK-NEXT:    xxlxor vs34, vs34, vs34
192; CHECK-NEXT:    blr
193
194entry:
195  ret <2 x double> zeroinitializer
196}
197
198define dso_local <2 x double> @testDoubleToDoubleNegZero() local_unnamed_addr {
199; CHECK-LABEL: testDoubleToDoubleNegZero:
200; CHECK:       # %bb.0: # %entry
201; CHECK-NEXT:    xxspltidp vs34, -2147483648
202; CHECK-NEXT:    blr
203
204entry:
205  ret <2 x double> <double -0.000000e+00, double -0.000000e+00>
206}
207
208define dso_local <2 x double> @testDoubleToDoubleNaN() local_unnamed_addr {
209; CHECK-LABEL: testDoubleToDoubleNaN:
210; CHECK:       # %bb.0: # %entry
211; CHECK-NEXT:    xxspltidp vs34, -16
212; CHECK-NEXT:    blr
213
214entry:
215  ret <2 x double> <double 0xFFFFFFFE00000000, double 0xFFFFFFFE00000000>
216}
217
218define dso_local <2 x double> @testDoubleToDoubleInfinity() local_unnamed_addr {
219; CHECK-LABEL: testDoubleToDoubleInfinity:
220; CHECK:       # %bb.0: # %entry
221; CHECK-NEXT:    xxspltidp vs34, 2139095040
222; CHECK-NEXT:    blr
223
224entry:
225  ret <2 x double> <double 0x7FF0000000000000, double 0x7FF0000000000000>
226}
227
228define dso_local <2 x double> @testFloatToDoubleNaN() local_unnamed_addr {
229; CHECK-LABEL: testFloatToDoubleNaN:
230; CHECK:       # %bb.0: # %entry
231; CHECK-NEXT:    xxspltidp vs34, -1
232; CHECK-NEXT:    blr
233
234entry:
235  ret <2 x double> <double 0xFFFFFFFFE0000000, double 0xFFFFFFFFE0000000>
236}
237
238define dso_local <2 x double> @testFloatToDoubleInfinity() local_unnamed_addr {
239; CHECK-LABEL: testFloatToDoubleInfinity:
240; CHECK:       # %bb.0: # %entry
241; CHECK-NEXT:    xxspltidp vs34, 2139095040
242; CHECK-NEXT:    blr
243
244entry:
245  ret <2 x double> <double 0x7FF0000000000000, double 0x7FF0000000000000>
246}
247
248define dso_local float @testFloatScalar() local_unnamed_addr {
249; CHECK-LABEL: testFloatScalar:
250; CHECK:       # %bb.0: # %entry
251; CHECK-NEXT:    xxspltidp vs1, 1135290941
252; CHECK-NEXT:    # kill: def $f1 killed $f1 killed $vsl1
253; CHECK-NEXT:    blr
254
255entry:
256  ret float 0x40756547A0000000
257}
258
259define dso_local float @testFloatZeroScalar() local_unnamed_addr {
260; CHECK-LABEL: testFloatZeroScalar:
261; CHECK:       # %bb.0: # %entry
262; CHECK-NEXT:    xxlxor f1, f1, f1
263; CHECK-NEXT:    blr
264
265entry:
266  ret float 0.000000e+00
267}
268
269define dso_local double @testDoubleRepresentableScalar() local_unnamed_addr {
270; CHECK-LABEL: testDoubleRepresentableScalar:
271; CHECK:       # %bb.0: # %entry
272; CHECK-NEXT:    xxspltidp vs1, 1135290941
273; CHECK-NEXT:    # kill: def $f1 killed $f1 killed $vsl1
274; CHECK-NEXT:    blr
275
276entry:
277  ret double 0x40756547A0000000
278}
279
280define dso_local double @testDoubleZeroScalar() local_unnamed_addr {
281; CHECK-LABEL: testDoubleZeroScalar:
282; CHECK:       # %bb.0: # %entry
283; CHECK-NEXT:    xxlxor f1, f1, f1
284; CHECK-NEXT:    blr
285
286entry:
287  ret double 0.000000e+00
288}
289
290define dso_local <4 x i32> @vec_splati() local_unnamed_addr {
291; CHECK-LABEL: vec_splati:
292; CHECK:       # %bb.0: # %entry
293; CHECK-NEXT:    xxspltiw vs34, -17
294; CHECK-NEXT:    blr
295entry:
296  ret <4 x i32> <i32 -17, i32 -17, i32 -17, i32 -17>
297}
298
299define dso_local <2 x double> @vec_splatid() local_unnamed_addr {
300; CHECK-LABEL: vec_splatid:
301; CHECK:       # %bb.0: # %entry
302; CHECK-NEXT:    xxspltidp vs34, 1065353216
303; CHECK-NEXT:    blr
304entry:
305  ret <2 x double> <double 1.000000e+00, double 1.000000e+00>
306}
307