1; Tests if we can read select instructions.
2
3; RUN: %p2i -i %s --insts | FileCheck %s
4; RUN:   %p2i -i %s --args -notranslate -timing | \
5; RUN:   FileCheck --check-prefix=NOIR %s
6
7define internal void @Seli1(i32 %p) {
8entry:
9  %vc = trunc i32 %p to i1
10  %vt = trunc i32 %p to i1
11  %ve = trunc i32 %p to i1
12  %r = select i1 %vc, i1 %vt, i1 %ve
13  ret void
14}
15
16; CHECK:      define internal void @Seli1(i32 %p) {
17; CHECK-NEXT: entry:
18; CHECK-NEXT:   %vc = trunc i32 %p to i1
19; CHECK-NEXT:   %vt = trunc i32 %p to i1
20; CHECK-NEXT:   %ve = trunc i32 %p to i1
21; CHECK-NEXT:   %r = select i1 %vc, i1 %vt, i1 %ve
22; CHECK-NEXT:   ret void
23; CHECK-NEXT: }
24
25define internal void @Seli8(i32 %p) {
26entry:
27  %vc = trunc i32 %p to i1
28  %vt = trunc i32 %p to i8
29  %ve = trunc i32 %p to i8
30  %r = select i1 %vc, i8 %vt, i8 %ve
31  ret void
32}
33
34; CHECK-NEXT: define internal void @Seli8(i32 %p) {
35; CHECK-NEXT: entry:
36; CHECK-NEXT:   %vc = trunc i32 %p to i1
37; CHECK-NEXT:   %vt = trunc i32 %p to i8
38; CHECK-NEXT:   %ve = trunc i32 %p to i8
39; CHECK-NEXT:   %r = select i1 %vc, i8 %vt, i8 %ve
40; CHECK-NEXT:   ret void
41; CHECK-NEXT: }
42
43define internal void @Seli16(i32 %p) {
44entry:
45  %vc = trunc i32 %p to i1
46  %vt = trunc i32 %p to i16
47  %ve = trunc i32 %p to i16
48  %r = select i1 %vc, i16 %vt, i16 %ve
49  ret void
50}
51
52; CHECK-NEXT: define internal void @Seli16(i32 %p) {
53; CHECK-NEXT: entry:
54; CHECK-NEXT:   %vc = trunc i32 %p to i1
55; CHECK-NEXT:   %vt = trunc i32 %p to i16
56; CHECK-NEXT:   %ve = trunc i32 %p to i16
57; CHECK-NEXT:   %r = select i1 %vc, i16 %vt, i16 %ve
58; CHECK-NEXT:   ret void
59; CHECK-NEXT: }
60
61define internal i32 @Seli32(i32 %pc, i32 %pt, i32 %pe) {
62entry:
63  %vc = trunc i32 %pc to i1
64  %r = select i1 %vc, i32 %pt, i32 %pe
65  ret i32 %r
66}
67
68; CHECK-NEXT: define internal i32 @Seli32(i32 %pc, i32 %pt, i32 %pe) {
69; CHECK-NEXT: entry:
70; CHECK-NEXT:   %vc = trunc i32 %pc to i1
71; CHECK-NEXT:   %r = select i1 %vc, i32 %pt, i32 %pe
72; CHECK-NEXT:   ret i32 %r
73; CHECK-NEXT: }
74
75define internal i64 @Seli64(i64 %pc, i64 %pt, i64 %pe) {
76entry:
77  %vc = trunc i64 %pc to i1
78  %r = select i1 %vc, i64 %pt, i64 %pe
79  ret i64 %r
80}
81
82; CHECK-NEXT: define internal i64 @Seli64(i64 %pc, i64 %pt, i64 %pe) {
83; CHECK-NEXT: entry:
84; CHECK-NEXT:   %vc = trunc i64 %pc to i1
85; CHECK-NEXT:   %r = select i1 %vc, i64 %pt, i64 %pe
86; CHECK-NEXT:   ret i64 %r
87; CHECK-NEXT: }
88
89define internal float @SelFloat(i32 %pc, float %pt, float %pe) {
90entry:
91  %vc = trunc i32 %pc to i1
92  %r = select i1 %vc, float %pt, float %pe
93  ret float %r
94}
95
96; CHECK-NEXT: define internal float @SelFloat(i32 %pc, float %pt, float %pe) {
97; CHECK-NEXT: entry:
98; CHECK-NEXT:   %vc = trunc i32 %pc to i1
99; CHECK-NEXT:   %r = select i1 %vc, float %pt, float %pe
100; CHECK-NEXT:   ret float %r
101; CHECK-NEXT: }
102
103define internal double @SelDouble(i32 %pc, double %pt, double %pe) {
104entry:
105  %vc = trunc i32 %pc to i1
106  %r = select i1 %vc, double %pt, double %pe
107  ret double %r
108}
109
110; CHECK-NEXT: define internal double @SelDouble(i32 %pc, double %pt, double %pe) {
111; CHECK-NEXT: entry:
112; CHECK-NEXT:   %vc = trunc i32 %pc to i1
113; CHECK-NEXT:   %r = select i1 %vc, double %pt, double %pe
114; CHECK-NEXT:   ret double %r
115; CHECK-NEXT: }
116
117define internal <16 x i1> @SelV16x1(i32 %pc, <16 x i1> %pt, <16 x i1> %pe) {
118entry:
119  %vc = trunc i32 %pc to i1
120  %r = select i1 %vc, <16 x i1> %pt, <16 x i1> %pe
121  ret <16 x i1> %r
122}
123
124; CHECK-NEXT: define internal <16 x i1> @SelV16x1(i32 %pc, <16 x i1> %pt, <16 x i1> %pe) {
125; CHECK-NEXT: entry:
126; CHECK-NEXT:   %vc = trunc i32 %pc to i1
127; CHECK-NEXT:   %r = select i1 %vc, <16 x i1> %pt, <16 x i1> %pe
128; CHECK-NEXT:   ret <16 x i1> %r
129; CHECK-NEXT: }
130
131define internal <8 x i1> @SelV8x1(i32 %pc, <8 x i1> %pt, <8 x i1> %pe) {
132entry:
133  %vc = trunc i32 %pc to i1
134  %r = select i1 %vc, <8 x i1> %pt, <8 x i1> %pe
135  ret <8 x i1> %r
136}
137
138; CHECK-NEXT: define internal <8 x i1> @SelV8x1(i32 %pc, <8 x i1> %pt, <8 x i1> %pe) {
139; CHECK-NEXT: entry:
140; CHECK-NEXT:   %vc = trunc i32 %pc to i1
141; CHECK-NEXT:   %r = select i1 %vc, <8 x i1> %pt, <8 x i1> %pe
142; CHECK-NEXT:   ret <8 x i1> %r
143; CHECK-NEXT: }
144
145define internal <4 x i1> @SelV4x1(i32 %pc, <4 x i1> %pt, <4 x i1> %pe) {
146entry:
147  %vc = trunc i32 %pc to i1
148  %r = select i1 %vc, <4 x i1> %pt, <4 x i1> %pe
149  ret <4 x i1> %r
150}
151
152; CHECK-NEXT: define internal <4 x i1> @SelV4x1(i32 %pc, <4 x i1> %pt, <4 x i1> %pe) {
153; CHECK-NEXT: entry:
154; CHECK-NEXT:   %vc = trunc i32 %pc to i1
155; CHECK-NEXT:   %r = select i1 %vc, <4 x i1> %pt, <4 x i1> %pe
156; CHECK-NEXT:   ret <4 x i1> %r
157; CHECK-NEXT: }
158
159define internal <16 x i8> @SelV16x8(i32 %pc, <16 x i8> %pt, <16 x i8> %pe) {
160entry:
161  %vc = trunc i32 %pc to i1
162  %r = select i1 %vc, <16 x i8> %pt, <16 x i8> %pe
163  ret <16 x i8> %r
164}
165
166; CHECK-NEXT: define internal <16 x i8> @SelV16x8(i32 %pc, <16 x i8> %pt, <16 x i8> %pe) {
167; CHECK-NEXT: entry:
168; CHECK-NEXT:   %vc = trunc i32 %pc to i1
169; CHECK-NEXT:   %r = select i1 %vc, <16 x i8> %pt, <16 x i8> %pe
170; CHECK-NEXT:   ret <16 x i8> %r
171; CHECK-NEXT: }
172
173define internal <8 x i16> @SelV8x16(i32 %pc, <8 x i16> %pt, <8 x i16> %pe) {
174entry:
175  %vc = trunc i32 %pc to i1
176  %r = select i1 %vc, <8 x i16> %pt, <8 x i16> %pe
177  ret <8 x i16> %r
178}
179
180; CHECK-NEXT: define internal <8 x i16> @SelV8x16(i32 %pc, <8 x i16> %pt, <8 x i16> %pe) {
181; CHECK-NEXT: entry:
182; CHECK-NEXT:   %vc = trunc i32 %pc to i1
183; CHECK-NEXT:   %r = select i1 %vc, <8 x i16> %pt, <8 x i16> %pe
184; CHECK-NEXT:   ret <8 x i16> %r
185; CHECK-NEXT: }
186
187define internal <4 x i32> @SelV4x32(i32 %pc, <4 x i32> %pt, <4 x i32> %pe) {
188entry:
189  %vc = trunc i32 %pc to i1
190  %r = select i1 %vc, <4 x i32> %pt, <4 x i32> %pe
191  ret <4 x i32> %r
192}
193
194; CHECK-NEXT: define internal <4 x i32> @SelV4x32(i32 %pc, <4 x i32> %pt, <4 x i32> %pe) {
195; CHECK-NEXT: entry:
196; CHECK-NEXT:   %vc = trunc i32 %pc to i1
197; CHECK-NEXT:   %r = select i1 %vc, <4 x i32> %pt, <4 x i32> %pe
198; CHECK-NEXT:   ret <4 x i32> %r
199; CHECK-NEXT: }
200
201define internal <4 x float> @SelV4xfloat(i32 %pc, <4 x float> %pt, <4 x float> %pe) {
202entry:
203  %vc = trunc i32 %pc to i1
204  %r = select i1 %vc, <4 x float> %pt, <4 x float> %pe
205  ret <4 x float> %r
206}
207
208; CHECK-NEXT: define internal <4 x float> @SelV4xfloat(i32 %pc, <4 x float> %pt, <4 x float> %pe) {
209; CHECK-NEXT: entry:
210; CHECK-NEXT:   %vc = trunc i32 %pc to i1
211; CHECK-NEXT:   %r = select i1 %vc, <4 x float> %pt, <4 x float> %pe
212; CHECK-NEXT:   ret <4 x float> %r
213; CHECK-NEXT: }
214
215define internal <16 x i1> @SelV16x1Vcond(<16 x i1> %pc, <16 x i1> %pt, <16 x i1> %pe) {
216entry:
217  %r = select <16 x i1> %pc, <16 x i1> %pt, <16 x i1> %pe
218  ret <16 x i1> %r
219}
220
221; CHECK-NEXT: define internal <16 x i1> @SelV16x1Vcond(<16 x i1> %pc, <16 x i1> %pt, <16 x i1> %pe) {
222; CHECK-NEXT: entry:
223; CHECK-NEXT:   %r = select <16 x i1> %pc, <16 x i1> %pt, <16 x i1> %pe
224; CHECK-NEXT:   ret <16 x i1> %r
225; CHECK-NEXT: }
226
227define internal <8 x i1> @SelV8x1Vcond(<8 x i1> %pc, <8 x i1> %pt, <8 x i1> %pe) {
228entry:
229  %r = select <8 x i1> %pc, <8 x i1> %pt, <8 x i1> %pe
230  ret <8 x i1> %r
231}
232
233; CHECK-NEXT: define internal <8 x i1> @SelV8x1Vcond(<8 x i1> %pc, <8 x i1> %pt, <8 x i1> %pe) {
234; CHECK-NEXT: entry:
235; CHECK-NEXT:   %r = select <8 x i1> %pc, <8 x i1> %pt, <8 x i1> %pe
236; CHECK-NEXT:   ret <8 x i1> %r
237; CHECK-NEXT: }
238
239define internal <4 x i1> @SelV4x1Vcond(<4 x i1> %pc, <4 x i1> %pt, <4 x i1> %pe) {
240entry:
241  %r = select <4 x i1> %pc, <4 x i1> %pt, <4 x i1> %pe
242  ret <4 x i1> %r
243}
244
245; CHECK-NEXT: define internal <4 x i1> @SelV4x1Vcond(<4 x i1> %pc, <4 x i1> %pt, <4 x i1> %pe) {
246; CHECK-NEXT: entry:
247; CHECK-NEXT:   %r = select <4 x i1> %pc, <4 x i1> %pt, <4 x i1> %pe
248; CHECK-NEXT:   ret <4 x i1> %r
249; CHECK-NEXT: }
250
251define internal <16 x i8> @SelV16x8Vcond(<16 x i1> %pc, <16 x i8> %pt, <16 x i8> %pe) {
252entry:
253  %r = select <16 x i1> %pc, <16 x i8> %pt, <16 x i8> %pe
254  ret <16 x i8> %r
255}
256
257; CHECK-NEXT: define internal <16 x i8> @SelV16x8Vcond(<16 x i1> %pc, <16 x i8> %pt, <16 x i8> %pe) {
258; CHECK-NEXT: entry:
259; CHECK-NEXT:   %r = select <16 x i1> %pc, <16 x i8> %pt, <16 x i8> %pe
260; CHECK-NEXT:   ret <16 x i8> %r
261; CHECK-NEXT: }
262
263define internal <8 x i16> @SelV8x16Vcond(<8 x i1> %pc, <8 x i16> %pt, <8 x i16> %pe) {
264entry:
265  %r = select <8 x i1> %pc, <8 x i16> %pt, <8 x i16> %pe
266  ret <8 x i16> %r
267}
268
269; CHECK-NEXT: define internal <8 x i16> @SelV8x16Vcond(<8 x i1> %pc, <8 x i16> %pt, <8 x i16> %pe) {
270; CHECK-NEXT: entry:
271; CHECK-NEXT:   %r = select <8 x i1> %pc, <8 x i16> %pt, <8 x i16> %pe
272; CHECK-NEXT:   ret <8 x i16> %r
273; CHECK-NEXT: }
274
275define internal <4 x i32> @SelV4x32Vcond(<4 x i1> %pc, <4 x i32> %pt, <4 x i32> %pe) {
276entry:
277  %r = select <4 x i1> %pc, <4 x i32> %pt, <4 x i32> %pe
278  ret <4 x i32> %r
279}
280
281; CHECK-NEXT: define internal <4 x i32> @SelV4x32Vcond(<4 x i1> %pc, <4 x i32> %pt, <4 x i32> %pe) {
282; CHECK-NEXT: entry:
283; CHECK-NEXT:   %r = select <4 x i1> %pc, <4 x i32> %pt, <4 x i32> %pe
284; CHECK-NEXT:   ret <4 x i32> %r
285; CHECK-NEXT: }
286
287define internal <4 x float> @SelV4xfloatVcond(<4 x i1> %pc, <4 x float> %pt, <4 x float> %pe) {
288entry:
289  %r = select <4 x i1> %pc, <4 x float> %pt, <4 x float> %pe
290  ret <4 x float> %r
291}
292
293; CHECK-NEXT: define internal <4 x float> @SelV4xfloatVcond(<4 x i1> %pc, <4 x float> %pt, <4 x float> %pe) {
294; CHECK-NEXT: entry:
295; CHECK-NEXT:   %r = select <4 x i1> %pc, <4 x float> %pt, <4 x float> %pe
296; CHECK-NEXT:   ret <4 x float> %r
297; CHECK-NEXT: }
298
299; NOIR: Total across all functions
300