OSDN Git Service

fortran/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / sse-9.c
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O2 -msse" } */
3 #include <xmmintrin.h>
4 #include <stdlib.h>
5 #include <stddef.h>
6 #include <string.h>
7 #include "../../gcc.dg/i386-cpuid.h"
8
9 int
10 main()
11 {
12   int alignment, n;
13   void *ptr;
14   int errors = 0;
15   const char test [] = "This is a test.";
16   unsigned long cpu_facilities;
17
18   cpu_facilities = i386_cpuid ();
19
20   if ((cpu_facilities & bit_SSE) != bit_SSE )
21     /* If host has no vector support, pass.  */
22     exit (0);
23
24   for (alignment = 1; alignment <= (1 << 20); alignment += alignment)
25     {
26       ptr = _mm_malloc (alignment, alignment);
27       if (((ptrdiff_t) ptr) & (alignment - 1))
28         abort ();
29       if (ptr)
30         {
31           n = alignment > sizeof test ? sizeof test : alignment;
32           memcpy (ptr, test, n);
33           if (memcmp (ptr, test, n) != 0)
34             errors++;
35           _mm_free (ptr);
36         }
37       else
38         errors++;
39     }
40    
41   if (errors != 0)
42     abort ();
43   exit (0);
44 }