OSDN Git Service

7417324e4bb49aa26b4046b441b68d9890d20534
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / stackalign / push-1.c
1 /* PR middle-end/37010 */
2 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
3 /* { dg-options "-msse2 -mpreferred-stack-boundary=2" } */
4
5 #include <emmintrin.h>
6 #include "cpuid.h"
7
8 typedef __PTRDIFF_TYPE__ ptrdiff_t;
9 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
10 typedef int aligned __attribute__((aligned(16)));
11
12 extern void abort (void);
13
14 __m128 r;
15
16 int
17 __attribute__ ((noinline))
18 check_int (int *i, int align)
19 {
20   *i = 20;
21   if ((((ptrdiff_t) i) & (align - 1)) != 0)
22     {
23       abort ();
24     }
25   return *i;
26 }
27
28 void
29 __attribute__ ((noinline))
30 foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
31 {
32   aligned i;
33
34   if (size != 5 || check_int (&i, __alignof__(i)) != i)
35     abort ();
36
37   r = a;
38 }
39
40 int
41 main (void)
42 {
43   __m128 x = { 1.0 };
44   unsigned int eax, ebx, ecx, edx;
45  
46   if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
47     return 0;
48
49   /* Run SSE2 test only if host has SSE2 support.  */
50   if (edx & bit_SSE2)
51     {
52       foo (x, x, x, x, 5);
53
54       if (__builtin_memcmp (&r, &x, sizeof (r)))
55         abort ();
56     }
57
58   return 0;
59 }