OSDN Git Service

47f3607c2a5a1477e18d89a3d4dbaf5de1302342
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / stackalign / alloca-3.c
1 /* PR middle-end/37009 */
2 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
3 /* { dg-options "-msse2" } */
4
5 #include <emmintrin.h>
6 #include "cpuid.h"
7 #include "check.h"
8
9 #ifndef ALIGNMENT
10 #define ALIGNMENT       16
11 #endif
12
13 typedef int aligned __attribute__((aligned(ALIGNMENT)));
14
15 void
16 bar (char *p, int size)
17 {
18   __builtin_strncpy (p, "good", size);
19 }
20
21 void
22 __attribute__ ((noinline))
23 foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
24 {
25   char *p = __builtin_alloca (size + 1);
26   aligned i;
27
28   bar (p, size);
29   if (__builtin_strncmp (p, "good", size) != 0)
30     {
31 #ifdef DEBUG
32       p[size] = '\0';
33       printf ("Failed: %s != good\n", p);
34 #endif
35       abort ();
36     }
37
38   if (check_int (&i,  __alignof__(i)) != i)
39     abort ();
40 }
41
42 int
43 main (void)
44 {
45   __m128 x = { 1.0 };
46   unsigned int eax, ebx, ecx, edx;
47  
48   if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
49     return 0;
50
51   /* Run SSE2 test only if host has SSE2 support.  */
52   if (edx & bit_SSE2)
53     foo (x, x, x, x, 5);
54
55   return 0;
56 }