| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -ffast-math -ftree-vectorize -msse4.1" } */ |
| 3 |
/* { dg-require-effective-target sse4 } */ |
| 4 |
/* { dg-require-effective-target c99_runtime } */ |
| 5 |
|
| 6 |
#ifndef CHECK_H |
| 7 |
#define CHECK_H "sse4_1-check.h" |
| 8 |
#endif |
| 9 |
|
| 10 |
#ifndef TEST |
| 11 |
#define TEST sse4_1_test |
| 12 |
#endif |
| 13 |
|
| 14 |
#include CHECK_H |
| 15 |
|
| 16 |
#define __NO_MATH_INLINES |
| 17 |
#include "math_m_pi.h" |
| 18 |
|
| 19 |
#define NUM 64 |
| 20 |
|
| 21 |
static void |
| 22 |
__attribute__((__target__("fpmath=sse"))) |
| 23 |
init_src (float *src) |
| 24 |
{ |
| 25 |
int i, sign = 1; |
| 26 |
float f = rand (); |
| 27 |
|
| 28 |
for (i = 0; i < NUM; i++) |
| 29 |
{ |
| 30 |
src[i] = (i + 1) * f * M_PI * sign; |
| 31 |
if (i < (NUM / 2)) |
| 32 |
{ |
| 33 |
if ((i % 6) == 0) |
| 34 |
f = f * src[i]; |
| 35 |
} |
| 36 |
else if (i == (NUM / 2)) |
| 37 |
f = rand (); |
| 38 |
else if ((i % 6) == 0) |
| 39 |
f = 1 / (f * (i + 1) * src[i] * M_PI * sign); |
| 40 |
sign = -sign; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
static void |
| 45 |
__attribute__((__target__("fpmath=387"))) |
| 46 |
TEST (void) |
| 47 |
{ |
| 48 |
float a[NUM]; |
| 49 |
int r[NUM]; |
| 50 |
int i; |
| 51 |
|
| 52 |
init_src (a); |
| 53 |
|
| 54 |
for (i = 0; i < NUM; i++) |
| 55 |
r[i] = (int) __builtin_floorf (a[i]); |
| 56 |
|
| 57 |
/* check results: */ |
| 58 |
for (i = 0; i < NUM; i++) |
| 59 |
if (r[i] != (int) __builtin_floorf (a[i])) |
| 60 |
abort(); |
| 61 |
} |