OSDN Git Service

gcc:
[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 /* { dg-require-effective-target sse2 } */
5
6 #include <emmintrin.h>
7 #include "cpuid.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
17 bar (char *p, int size)
18 {
19   __builtin_strncpy (p, "good", size);
20 }
21
22 void
23 __attribute__ ((noinline))
24 foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
25 {
26   char *p = __builtin_alloca (size + 1);
27   aligned i;
28
29   bar (p, size);
30   if (__builtin_strncmp (p, "good", size) != 0)
31     {
32 #ifdef DEBUG
33       p[size] = '\0';
34       printf ("Failed: %s != good\n", p);
35 #endif
36       abort ();
37     }
38
39   if (check_int (&i,  __alignof__(i)) != i)
40     abort ();
41 }
42
43 int
44 main (void)
45 {
46   __m128 x = { 1.0 };
47   unsigned int eax, ebx, ecx, edx;
48  
49   if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
50     return 0;
51
52   /* Run SSE2 test only if host has SSE2 support.  */
53   if (edx & bit_SSE2)
54     foo (x, x, x, x, 5);
55
56   return 0;
57 }