| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -msse" } */ |
| 3 |
/* { dg-require-effective-target sse } */ |
| 4 |
|
| 5 |
#include "sse-check.h" |
| 6 |
|
| 7 |
#include <xmmintrin.h> |
| 8 |
#include <stddef.h> |
| 9 |
#include <string.h> |
| 10 |
|
| 11 |
static void |
| 12 |
sse_test (void) |
| 13 |
{ |
| 14 |
int alignment, n; |
| 15 |
void *ptr; |
| 16 |
int errors = 0; |
| 17 |
const char test [] = "This is a test."; |
| 18 |
|
| 19 |
for (alignment = 1; alignment <= (1 << 20); alignment += alignment) |
| 20 |
{ |
| 21 |
ptr = _mm_malloc (alignment, alignment); |
| 22 |
if (((ptrdiff_t) ptr) & (alignment - 1)) |
| 23 |
abort (); |
| 24 |
if (ptr) |
| 25 |
{ |
| 26 |
n = alignment > sizeof test ? sizeof test : alignment; |
| 27 |
memcpy (ptr, test, n); |
| 28 |
if (memcmp (ptr, test, n) != 0) |
| 29 |
errors++; |
| 30 |
_mm_free (ptr); |
| 31 |
} |
| 32 |
else |
| 33 |
errors++; |
| 34 |
} |
| 35 |
|
| 36 |
if (errors != 0) |
| 37 |
abort (); |
| 38 |
} |