1 /* PR middle-end/37009 */
2 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
3 /* { dg-additional-options "-mmmx -msse2" } */
4 /* { dg-require-effective-target sse2_runtime } */
5
6 #include <stdarg.h>
7 #include <emmintrin.h>
8 #include "check.h"
9
10 #ifndef ALIGNMENT
11 #define ALIGNMENT 16
12 #endif
13
14 typedef int aligned __attribute__((aligned(ALIGNMENT)));
15
16 void
bar(char * p,int size)17 bar (char *p, int size)
18 {
19 __builtin_strncpy (p, "good", size);
20 }
21
22 __m128 a = { 1.0 };
23
24 void
test(va_list arg)25 test (va_list arg)
26 {
27 char *p;
28 aligned i;
29 int size;
30 double x;
31 __m128 e;
32
33 size = va_arg (arg, int);
34 if (size != 5)
35 abort ();
36
37 p = __builtin_alloca (size + 1);
38
39 x = va_arg (arg, double);
40 if (x != 5.0)
41 abort ();
42
43 bar (p, size);
44 if (__builtin_strncmp (p, "good", size) != 0)
45 {
46 #ifdef DEBUG
47 p[size] = '\0';
48 printf ("Failed: %s != good\n", p);
49 #endif
50 abort ();
51 }
52
53 if (check_int (&i, __alignof__(i)) != i)
54 abort ();
55
56 e = va_arg (arg, __m128);
57 if (__builtin_memcmp (&e, &a, sizeof (e)))
58 abort ();
59 }
60
61 void
foo(const char * fmt,...)62 foo (const char *fmt, ...)
63 {
64 va_list arg;
65 va_start (arg, fmt);
66 test (arg);
67 va_end (arg);
68 }
69
70 int
main(void)71 main (void)
72 {
73 __m128 x = { 1.0 };
74
75 foo ("foo", 5, 5.0, x);
76
77 return 0;
78 }
79