1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple arm64-apple-ios7 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc #include <stdarg.h>
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(3) ))  char __char3;
6*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(4) ))  char __char4;
7*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(5) ))  char __char5;
8*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(9) ))  char __char9;
9*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(19) )) char __char19;
10*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(3) ))  short __short3;
11*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(5) ))  short __short5;
12*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(3) ))  int __int3;
13*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(5) ))  int __int5;
14*0a6a1f1dSLionel Sambuc typedef __attribute__(( ext_vector_type(3) ))  double __double3;
15*0a6a1f1dSLionel Sambuc 
varargs_vec_3c(int fixed,...)16*0a6a1f1dSLionel Sambuc double varargs_vec_3c(int fixed, ...) {
17*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_3c
18*0a6a1f1dSLionel Sambuc // CHECK: alloca <3 x i8>, align 4
19*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
20*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <3 x i8>*
21*0a6a1f1dSLionel Sambuc   va_list ap;
22*0a6a1f1dSLionel Sambuc   double sum = fixed;
23*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
24*0a6a1f1dSLionel Sambuc   __char3 c3 = va_arg(ap, __char3);
25*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
26*0a6a1f1dSLionel Sambuc   va_end(ap);
27*0a6a1f1dSLionel Sambuc   return sum;
28*0a6a1f1dSLionel Sambuc }
29*0a6a1f1dSLionel Sambuc 
test_3c(__char3 * in)30*0a6a1f1dSLionel Sambuc double test_3c(__char3 *in) {
31*0a6a1f1dSLionel Sambuc // CHECK: test_3c
32*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_3c(i32 3, i32 {{%.*}})
33*0a6a1f1dSLionel Sambuc   return varargs_vec_3c(3, *in);
34*0a6a1f1dSLionel Sambuc }
35*0a6a1f1dSLionel Sambuc 
varargs_vec_4c(int fixed,...)36*0a6a1f1dSLionel Sambuc double varargs_vec_4c(int fixed, ...) {
37*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_4c
38*0a6a1f1dSLionel Sambuc // CHECK: alloca <4 x i8>, align 4
39*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
40*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <4 x i8>*
41*0a6a1f1dSLionel Sambuc   va_list ap;
42*0a6a1f1dSLionel Sambuc   double sum = fixed;
43*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
44*0a6a1f1dSLionel Sambuc   __char4 c4 = va_arg(ap, __char4);
45*0a6a1f1dSLionel Sambuc   sum = sum + c4.x + c4.y;
46*0a6a1f1dSLionel Sambuc   va_end(ap);
47*0a6a1f1dSLionel Sambuc   return sum;
48*0a6a1f1dSLionel Sambuc }
49*0a6a1f1dSLionel Sambuc 
test_4c(__char4 * in)50*0a6a1f1dSLionel Sambuc double test_4c(__char4 *in) {
51*0a6a1f1dSLionel Sambuc // CHECK: test_4c
52*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_4c(i32 4, i32 {{%.*}})
53*0a6a1f1dSLionel Sambuc   return varargs_vec_4c(4, *in);
54*0a6a1f1dSLionel Sambuc }
55*0a6a1f1dSLionel Sambuc 
varargs_vec_5c(int fixed,...)56*0a6a1f1dSLionel Sambuc double varargs_vec_5c(int fixed, ...) {
57*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_5c
58*0a6a1f1dSLionel Sambuc // CHECK: alloca <5 x i8>, align 8
59*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
60*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <5 x i8>*
61*0a6a1f1dSLionel Sambuc   va_list ap;
62*0a6a1f1dSLionel Sambuc   double sum = fixed;
63*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
64*0a6a1f1dSLionel Sambuc   __char5 c5 = va_arg(ap, __char5);
65*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
66*0a6a1f1dSLionel Sambuc   va_end(ap);
67*0a6a1f1dSLionel Sambuc   return sum;
68*0a6a1f1dSLionel Sambuc }
69*0a6a1f1dSLionel Sambuc 
test_5c(__char5 * in)70*0a6a1f1dSLionel Sambuc double test_5c(__char5 *in) {
71*0a6a1f1dSLionel Sambuc // CHECK: test_5c
72*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
73*0a6a1f1dSLionel Sambuc   return varargs_vec_5c(5, *in);
74*0a6a1f1dSLionel Sambuc }
75*0a6a1f1dSLionel Sambuc 
varargs_vec_9c(int fixed,...)76*0a6a1f1dSLionel Sambuc double varargs_vec_9c(int fixed, ...) {
77*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_9c
78*0a6a1f1dSLionel Sambuc // CHECK: alloca <9 x i8>, align 16
79*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
80*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
81*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
82*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <9 x i8>*
83*0a6a1f1dSLionel Sambuc   va_list ap;
84*0a6a1f1dSLionel Sambuc   double sum = fixed;
85*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
86*0a6a1f1dSLionel Sambuc   __char9 c9 = va_arg(ap, __char9);
87*0a6a1f1dSLionel Sambuc   sum = sum + c9.x + c9.y;
88*0a6a1f1dSLionel Sambuc   va_end(ap);
89*0a6a1f1dSLionel Sambuc   return sum;
90*0a6a1f1dSLionel Sambuc }
91*0a6a1f1dSLionel Sambuc 
test_9c(__char9 * in)92*0a6a1f1dSLionel Sambuc double test_9c(__char9 *in) {
93*0a6a1f1dSLionel Sambuc // CHECK: test_9c
94*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
95*0a6a1f1dSLionel Sambuc   return varargs_vec_9c(9, *in);
96*0a6a1f1dSLionel Sambuc }
97*0a6a1f1dSLionel Sambuc 
varargs_vec_19c(int fixed,...)98*0a6a1f1dSLionel Sambuc double varargs_vec_19c(int fixed, ...) {
99*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_19c
100*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
101*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
102*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
103*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <19 x i8>*
104*0a6a1f1dSLionel Sambuc   va_list ap;
105*0a6a1f1dSLionel Sambuc   double sum = fixed;
106*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
107*0a6a1f1dSLionel Sambuc   __char19 c19 = va_arg(ap, __char19);
108*0a6a1f1dSLionel Sambuc   sum = sum + c19.x + c19.y;
109*0a6a1f1dSLionel Sambuc   va_end(ap);
110*0a6a1f1dSLionel Sambuc   return sum;
111*0a6a1f1dSLionel Sambuc }
112*0a6a1f1dSLionel Sambuc 
test_19c(__char19 * in)113*0a6a1f1dSLionel Sambuc double test_19c(__char19 *in) {
114*0a6a1f1dSLionel Sambuc // CHECK: test_19c
115*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_19c(i32 19, <19 x i8>* {{%.*}})
116*0a6a1f1dSLionel Sambuc   return varargs_vec_19c(19, *in);
117*0a6a1f1dSLionel Sambuc }
118*0a6a1f1dSLionel Sambuc 
varargs_vec_3s(int fixed,...)119*0a6a1f1dSLionel Sambuc double varargs_vec_3s(int fixed, ...) {
120*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_3s
121*0a6a1f1dSLionel Sambuc // CHECK: alloca <3 x i16>, align 8
122*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
123*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <3 x i16>*
124*0a6a1f1dSLionel Sambuc   va_list ap;
125*0a6a1f1dSLionel Sambuc   double sum = fixed;
126*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
127*0a6a1f1dSLionel Sambuc   __short3 c3 = va_arg(ap, __short3);
128*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
129*0a6a1f1dSLionel Sambuc   va_end(ap);
130*0a6a1f1dSLionel Sambuc   return sum;
131*0a6a1f1dSLionel Sambuc }
132*0a6a1f1dSLionel Sambuc 
test_3s(__short3 * in)133*0a6a1f1dSLionel Sambuc double test_3s(__short3 *in) {
134*0a6a1f1dSLionel Sambuc // CHECK: test_3s
135*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_3s(i32 3, <2 x i32> {{%.*}})
136*0a6a1f1dSLionel Sambuc   return varargs_vec_3s(3, *in);
137*0a6a1f1dSLionel Sambuc }
138*0a6a1f1dSLionel Sambuc 
varargs_vec_5s(int fixed,...)139*0a6a1f1dSLionel Sambuc double varargs_vec_5s(int fixed, ...) {
140*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_5s
141*0a6a1f1dSLionel Sambuc // CHECK: alloca <5 x i16>, align 16
142*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
143*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
144*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
145*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <5 x i16>*
146*0a6a1f1dSLionel Sambuc   va_list ap;
147*0a6a1f1dSLionel Sambuc   double sum = fixed;
148*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
149*0a6a1f1dSLionel Sambuc   __short5 c5 = va_arg(ap, __short5);
150*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
151*0a6a1f1dSLionel Sambuc   va_end(ap);
152*0a6a1f1dSLionel Sambuc   return sum;
153*0a6a1f1dSLionel Sambuc }
154*0a6a1f1dSLionel Sambuc 
test_5s(__short5 * in)155*0a6a1f1dSLionel Sambuc double test_5s(__short5 *in) {
156*0a6a1f1dSLionel Sambuc // CHECK: test_5s
157*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_5s(i32 5, <4 x i32> {{%.*}})
158*0a6a1f1dSLionel Sambuc   return varargs_vec_5s(5, *in);
159*0a6a1f1dSLionel Sambuc }
160*0a6a1f1dSLionel Sambuc 
varargs_vec_3i(int fixed,...)161*0a6a1f1dSLionel Sambuc double varargs_vec_3i(int fixed, ...) {
162*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_3i
163*0a6a1f1dSLionel Sambuc // CHECK: alloca <3 x i32>, align 16
164*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
165*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
166*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
167*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <3 x i32>*
168*0a6a1f1dSLionel Sambuc   va_list ap;
169*0a6a1f1dSLionel Sambuc   double sum = fixed;
170*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
171*0a6a1f1dSLionel Sambuc   __int3 c3 = va_arg(ap, __int3);
172*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
173*0a6a1f1dSLionel Sambuc   va_end(ap);
174*0a6a1f1dSLionel Sambuc   return sum;
175*0a6a1f1dSLionel Sambuc }
176*0a6a1f1dSLionel Sambuc 
test_3i(__int3 * in)177*0a6a1f1dSLionel Sambuc double test_3i(__int3 *in) {
178*0a6a1f1dSLionel Sambuc // CHECK: test_3i
179*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_3i(i32 3, <4 x i32> {{%.*}})
180*0a6a1f1dSLionel Sambuc   return varargs_vec_3i(3, *in);
181*0a6a1f1dSLionel Sambuc }
182*0a6a1f1dSLionel Sambuc 
varargs_vec_5i(int fixed,...)183*0a6a1f1dSLionel Sambuc double varargs_vec_5i(int fixed, ...) {
184*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_5i
185*0a6a1f1dSLionel Sambuc // CHECK: alloca <5 x i32>, align 16
186*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
187*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
188*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
189*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <5 x i32>*
190*0a6a1f1dSLionel Sambuc   va_list ap;
191*0a6a1f1dSLionel Sambuc   double sum = fixed;
192*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
193*0a6a1f1dSLionel Sambuc   __int5 c5 = va_arg(ap, __int5);
194*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
195*0a6a1f1dSLionel Sambuc   va_end(ap);
196*0a6a1f1dSLionel Sambuc   return sum;
197*0a6a1f1dSLionel Sambuc }
198*0a6a1f1dSLionel Sambuc 
test_5i(__int5 * in)199*0a6a1f1dSLionel Sambuc double test_5i(__int5 *in) {
200*0a6a1f1dSLionel Sambuc // CHECK: test_5i
201*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_5i(i32 5, <5 x i32>* {{%.*}})
202*0a6a1f1dSLionel Sambuc   return varargs_vec_5i(5, *in);
203*0a6a1f1dSLionel Sambuc }
204*0a6a1f1dSLionel Sambuc 
varargs_vec_3d(int fixed,...)205*0a6a1f1dSLionel Sambuc double varargs_vec_3d(int fixed, ...) {
206*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec_3d
207*0a6a1f1dSLionel Sambuc // CHECK: alloca <3 x double>, align 16
208*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
209*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
210*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
211*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <3 x double>*
212*0a6a1f1dSLionel Sambuc   va_list ap;
213*0a6a1f1dSLionel Sambuc   double sum = fixed;
214*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
215*0a6a1f1dSLionel Sambuc   __double3 c3 = va_arg(ap, __double3);
216*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
217*0a6a1f1dSLionel Sambuc   va_end(ap);
218*0a6a1f1dSLionel Sambuc   return sum;
219*0a6a1f1dSLionel Sambuc }
220*0a6a1f1dSLionel Sambuc 
test_3d(__double3 * in)221*0a6a1f1dSLionel Sambuc double test_3d(__double3 *in) {
222*0a6a1f1dSLionel Sambuc // CHECK: test_3d
223*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec_3d(i32 3, <3 x double>* {{%.*}})
224*0a6a1f1dSLionel Sambuc   return varargs_vec_3d(3, *in);
225*0a6a1f1dSLionel Sambuc }
226*0a6a1f1dSLionel Sambuc 
varargs_vec(int fixed,...)227*0a6a1f1dSLionel Sambuc double varargs_vec(int fixed, ...) {
228*0a6a1f1dSLionel Sambuc // CHECK: varargs_vec
229*0a6a1f1dSLionel Sambuc   va_list ap;
230*0a6a1f1dSLionel Sambuc   double sum = fixed;
231*0a6a1f1dSLionel Sambuc   va_start(ap, fixed);
232*0a6a1f1dSLionel Sambuc   __char3 c3 = va_arg(ap, __char3);
233*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
234*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <3 x i8>*
235*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
236*0a6a1f1dSLionel Sambuc   __char5 c5 = va_arg(ap, __char5);
237*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
238*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <5 x i8>*
239*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
240*0a6a1f1dSLionel Sambuc   __char9 c9 = va_arg(ap, __char9);
241*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
242*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
243*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
244*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <9 x i8>*
245*0a6a1f1dSLionel Sambuc   sum = sum + c9.x + c9.y;
246*0a6a1f1dSLionel Sambuc   __char19 c19 = va_arg(ap, __char19);
247*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
248*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
249*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
250*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <19 x i8>*
251*0a6a1f1dSLionel Sambuc   sum = sum + c19.x + c19.y;
252*0a6a1f1dSLionel Sambuc   __short3 s3 = va_arg(ap, __short3);
253*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
254*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_CUR]] to <3 x i16>*
255*0a6a1f1dSLionel Sambuc   sum = sum + s3.x + s3.y;
256*0a6a1f1dSLionel Sambuc   __short5 s5 = va_arg(ap, __short5);
257*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
258*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
259*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
260*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <5 x i16>*
261*0a6a1f1dSLionel Sambuc   sum = sum + s5.x + s5.y;
262*0a6a1f1dSLionel Sambuc   __int3 i3 = va_arg(ap, __int3);
263*0a6a1f1dSLionel Sambuc // CHECK: [[ALIGN:%.*]] = and i64 {{%.*}}, -16
264*0a6a1f1dSLionel Sambuc // CHECK: [[AP_ALIGN:%.*]] = inttoptr i64 [[ALIGN]] to i8*
265*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_ALIGN]], i32 16
266*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[AP_ALIGN]] to <3 x i32>*
267*0a6a1f1dSLionel Sambuc   sum = sum + i3.x + i3.y;
268*0a6a1f1dSLionel Sambuc   __int5 i5 = va_arg(ap, __int5);
269*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
270*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
271*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
272*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <5 x i32>*
273*0a6a1f1dSLionel Sambuc   sum = sum + i5.x + i5.y;
274*0a6a1f1dSLionel Sambuc   __double3 d3 = va_arg(ap, __double3);
275*0a6a1f1dSLionel Sambuc // CHECK: [[AP_NEXT:%.*]] = getelementptr i8* [[AP_CUR:%.*]], i32 8
276*0a6a1f1dSLionel Sambuc // CHECK: [[VAR:%.*]] = bitcast i8* [[AP_CUR]] to i8**
277*0a6a1f1dSLionel Sambuc // CHECK: [[VAR2:%.*]] = load i8** [[VAR]]
278*0a6a1f1dSLionel Sambuc // CHECK: bitcast i8* [[VAR2]] to <3 x double>*
279*0a6a1f1dSLionel Sambuc   sum = sum + d3.x + d3.y;
280*0a6a1f1dSLionel Sambuc   va_end(ap);
281*0a6a1f1dSLionel Sambuc   return sum;
282*0a6a1f1dSLionel Sambuc }
283*0a6a1f1dSLionel Sambuc 
test(__char3 * c3,__char5 * c5,__char9 * c9,__char19 * c19,__short3 * s3,__short5 * s5,__int3 * i3,__int5 * i5,__double3 * d3)284*0a6a1f1dSLionel Sambuc double test(__char3 *c3, __char5 *c5, __char9 *c9, __char19 *c19,
285*0a6a1f1dSLionel Sambuc             __short3 *s3, __short5 *s5, __int3 *i3, __int5 *i5,
286*0a6a1f1dSLionel Sambuc             __double3 *d3) {
287*0a6a1f1dSLionel Sambuc   double ret = varargs_vec(3, *c3, *c5, *c9, *c19, *s3, *s5, *i3, *i5, *d3);
288*0a6a1f1dSLionel Sambuc // CHECK: call double (i32, ...)* @varargs_vec(i32 3, i32 {{%.*}}, <2 x i32> {{%.*}}, <4 x i32> {{%.*}}, <19 x i8>* {{%.*}}, <2 x i32> {{%.*}}, <4 x i32> {{%.*}}, <4 x i32> {{%.*}}, <5 x i32>* {{%.*}}, <3 x double>* {{%.*}})
289*0a6a1f1dSLionel Sambuc   return ret;
290*0a6a1f1dSLionel Sambuc }
291*0a6a1f1dSLionel Sambuc 
args_vec_3c(int fixed,__char3 c3)292*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_3c(int fixed, __char3 c3) {
293*0a6a1f1dSLionel Sambuc // CHECK: args_vec_3c
294*0a6a1f1dSLionel Sambuc // CHECK: [[C3:%.*]] = alloca <3 x i8>, align 4
295*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <3 x i8>* [[C3]] to i32*
296*0a6a1f1dSLionel Sambuc // CHECK: store i32 {{%.*}}, i32* [[TMP]]
297*0a6a1f1dSLionel Sambuc   double sum = fixed;
298*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
299*0a6a1f1dSLionel Sambuc   return sum;
300*0a6a1f1dSLionel Sambuc }
301*0a6a1f1dSLionel Sambuc 
fixed_3c(__char3 * in)302*0a6a1f1dSLionel Sambuc double fixed_3c(__char3 *in) {
303*0a6a1f1dSLionel Sambuc // CHECK: fixed_3c
304*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_3c(i32 3, i32 {{%.*}})
305*0a6a1f1dSLionel Sambuc   return args_vec_3c(3, *in);
306*0a6a1f1dSLionel Sambuc }
307*0a6a1f1dSLionel Sambuc 
args_vec_5c(int fixed,__char5 c5)308*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_5c(int fixed, __char5 c5) {
309*0a6a1f1dSLionel Sambuc // CHECK: args_vec_5c
310*0a6a1f1dSLionel Sambuc // CHECK: [[C5:%.*]] = alloca <5 x i8>, align 8
311*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <5 x i8>* [[C5]] to <2 x i32>*
312*0a6a1f1dSLionel Sambuc // CHECK: store <2 x i32> {{%.*}}, <2 x i32>* [[TMP]], align 1
313*0a6a1f1dSLionel Sambuc   double sum = fixed;
314*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
315*0a6a1f1dSLionel Sambuc   return sum;
316*0a6a1f1dSLionel Sambuc }
317*0a6a1f1dSLionel Sambuc 
fixed_5c(__char5 * in)318*0a6a1f1dSLionel Sambuc double fixed_5c(__char5 *in) {
319*0a6a1f1dSLionel Sambuc // CHECK: fixed_5c
320*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_5c(i32 5, <2 x i32> {{%.*}})
321*0a6a1f1dSLionel Sambuc   return args_vec_5c(5, *in);
322*0a6a1f1dSLionel Sambuc }
323*0a6a1f1dSLionel Sambuc 
args_vec_9c(int fixed,__char9 c9)324*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_9c(int fixed, __char9 c9) {
325*0a6a1f1dSLionel Sambuc // CHECK: args_vec_9c
326*0a6a1f1dSLionel Sambuc // CHECK: [[C9:%.*]] = alloca <9 x i8>, align 16
327*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <9 x i8>* [[C9]] to <4 x i32>*
328*0a6a1f1dSLionel Sambuc // CHECK: store <4 x i32> {{%.*}}, <4 x i32>* [[TMP]], align 1
329*0a6a1f1dSLionel Sambuc   double sum = fixed;
330*0a6a1f1dSLionel Sambuc   sum = sum + c9.x + c9.y;
331*0a6a1f1dSLionel Sambuc   return sum;
332*0a6a1f1dSLionel Sambuc }
333*0a6a1f1dSLionel Sambuc 
fixed_9c(__char9 * in)334*0a6a1f1dSLionel Sambuc double fixed_9c(__char9 *in) {
335*0a6a1f1dSLionel Sambuc // CHECK: fixed_9c
336*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_9c(i32 9, <4 x i32> {{%.*}})
337*0a6a1f1dSLionel Sambuc   return args_vec_9c(9, *in);
338*0a6a1f1dSLionel Sambuc }
339*0a6a1f1dSLionel Sambuc 
args_vec_19c(int fixed,__char19 c19)340*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_19c(int fixed, __char19 c19) {
341*0a6a1f1dSLionel Sambuc // CHECK: args_vec_19c
342*0a6a1f1dSLionel Sambuc // CHECK: [[C19:%.*]] = load <19 x i8>* {{.*}}, align 16
343*0a6a1f1dSLionel Sambuc   double sum = fixed;
344*0a6a1f1dSLionel Sambuc   sum = sum + c19.x + c19.y;
345*0a6a1f1dSLionel Sambuc   return sum;
346*0a6a1f1dSLionel Sambuc }
347*0a6a1f1dSLionel Sambuc 
fixed_19c(__char19 * in)348*0a6a1f1dSLionel Sambuc double fixed_19c(__char19 *in) {
349*0a6a1f1dSLionel Sambuc // CHECK: fixed_19c
350*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_19c(i32 19, <19 x i8>* {{%.*}})
351*0a6a1f1dSLionel Sambuc   return args_vec_19c(19, *in);
352*0a6a1f1dSLionel Sambuc }
353*0a6a1f1dSLionel Sambuc 
args_vec_3s(int fixed,__short3 c3)354*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_3s(int fixed, __short3 c3) {
355*0a6a1f1dSLionel Sambuc // CHECK: args_vec_3s
356*0a6a1f1dSLionel Sambuc // CHECK: [[C3:%.*]] = alloca <3 x i16>, align 8
357*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <3 x i16>* [[C3]] to <2 x i32>*
358*0a6a1f1dSLionel Sambuc // CHECK: store <2 x i32> {{%.*}}, <2 x i32>* [[TMP]], align 1
359*0a6a1f1dSLionel Sambuc   double sum = fixed;
360*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
361*0a6a1f1dSLionel Sambuc   return sum;
362*0a6a1f1dSLionel Sambuc }
363*0a6a1f1dSLionel Sambuc 
fixed_3s(__short3 * in)364*0a6a1f1dSLionel Sambuc double fixed_3s(__short3 *in) {
365*0a6a1f1dSLionel Sambuc // CHECK: fixed_3s
366*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_3s(i32 3, <2 x i32> {{%.*}})
367*0a6a1f1dSLionel Sambuc   return args_vec_3s(3, *in);
368*0a6a1f1dSLionel Sambuc }
369*0a6a1f1dSLionel Sambuc 
args_vec_5s(int fixed,__short5 c5)370*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_5s(int fixed, __short5 c5) {
371*0a6a1f1dSLionel Sambuc // CHECK: args_vec_5s
372*0a6a1f1dSLionel Sambuc // CHECK: [[C5:%.*]] = alloca <5 x i16>, align 16
373*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <5 x i16>* [[C5]] to <4 x i32>*
374*0a6a1f1dSLionel Sambuc // CHECK: store <4 x i32> {{%.*}}, <4 x i32>* [[TMP]], align 1
375*0a6a1f1dSLionel Sambuc   double sum = fixed;
376*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
377*0a6a1f1dSLionel Sambuc   return sum;
378*0a6a1f1dSLionel Sambuc }
379*0a6a1f1dSLionel Sambuc 
fixed_5s(__short5 * in)380*0a6a1f1dSLionel Sambuc double fixed_5s(__short5 *in) {
381*0a6a1f1dSLionel Sambuc // CHECK: fixed_5s
382*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_5s(i32 5, <4 x i32> {{%.*}})
383*0a6a1f1dSLionel Sambuc   return args_vec_5s(5, *in);
384*0a6a1f1dSLionel Sambuc }
385*0a6a1f1dSLionel Sambuc 
args_vec_3i(int fixed,__int3 c3)386*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_3i(int fixed, __int3 c3) {
387*0a6a1f1dSLionel Sambuc // CHECK: args_vec_3i
388*0a6a1f1dSLionel Sambuc // CHECK: [[C3:%.*]] = alloca <3 x i32>, align 16
389*0a6a1f1dSLionel Sambuc // CHECK: [[TMP:%.*]] = bitcast <3 x i32>* [[C3]] to <4 x i32>*
390*0a6a1f1dSLionel Sambuc // CHECK: store <4 x i32> {{%.*}}, <4 x i32>* [[TMP]], align 1
391*0a6a1f1dSLionel Sambuc   double sum = fixed;
392*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
393*0a6a1f1dSLionel Sambuc   return sum;
394*0a6a1f1dSLionel Sambuc }
395*0a6a1f1dSLionel Sambuc 
fixed_3i(__int3 * in)396*0a6a1f1dSLionel Sambuc double fixed_3i(__int3 *in) {
397*0a6a1f1dSLionel Sambuc // CHECK: fixed_3i
398*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_3i(i32 3, <4 x i32> {{%.*}})
399*0a6a1f1dSLionel Sambuc   return args_vec_3i(3, *in);
400*0a6a1f1dSLionel Sambuc }
401*0a6a1f1dSLionel Sambuc 
args_vec_5i(int fixed,__int5 c5)402*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_5i(int fixed, __int5 c5) {
403*0a6a1f1dSLionel Sambuc // CHECK: args_vec_5i
404*0a6a1f1dSLionel Sambuc // CHECK: [[C5:%.*]] = load <5 x i32>* {{%.*}}, align 16
405*0a6a1f1dSLionel Sambuc   double sum = fixed;
406*0a6a1f1dSLionel Sambuc   sum = sum + c5.x + c5.y;
407*0a6a1f1dSLionel Sambuc   return sum;
408*0a6a1f1dSLionel Sambuc }
409*0a6a1f1dSLionel Sambuc 
fixed_5i(__int5 * in)410*0a6a1f1dSLionel Sambuc double fixed_5i(__int5 *in) {
411*0a6a1f1dSLionel Sambuc // CHECK: fixed_5i
412*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_5i(i32 5, <5 x i32>* {{%.*}})
413*0a6a1f1dSLionel Sambuc   return args_vec_5i(5, *in);
414*0a6a1f1dSLionel Sambuc }
415*0a6a1f1dSLionel Sambuc 
args_vec_3d(int fixed,__double3 c3)416*0a6a1f1dSLionel Sambuc __attribute__((noinline)) double args_vec_3d(int fixed, __double3 c3) {
417*0a6a1f1dSLionel Sambuc // CHECK: args_vec_3d
418*0a6a1f1dSLionel Sambuc // CHECK: [[CAST:%.*]] = bitcast <3 x double>* {{%.*}} to <4 x double>*
419*0a6a1f1dSLionel Sambuc // CHECK: [[LOAD:%.*]] = load <4 x double>* [[CAST]]
420*0a6a1f1dSLionel Sambuc // CHECK: shufflevector <4 x double> [[LOAD]], <4 x double> undef, <3 x i32> <i32 0, i32 1, i32 2>
421*0a6a1f1dSLionel Sambuc   double sum = fixed;
422*0a6a1f1dSLionel Sambuc   sum = sum + c3.x + c3.y;
423*0a6a1f1dSLionel Sambuc   return sum;
424*0a6a1f1dSLionel Sambuc }
425*0a6a1f1dSLionel Sambuc 
fixed_3d(__double3 * in)426*0a6a1f1dSLionel Sambuc double fixed_3d(__double3 *in) {
427*0a6a1f1dSLionel Sambuc // CHECK: fixed_3d
428*0a6a1f1dSLionel Sambuc // CHECK: call double @args_vec_3d(i32 3, <3 x double>* {{%.*}})
429*0a6a1f1dSLionel Sambuc   return args_vec_3d(3, *in);
430*0a6a1f1dSLionel Sambuc }
431