2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-floor-sfix-vec.c
blob2083a60e7fe993474ce34ef4ef9ea3d3ac4146cd
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse4.1" } */
3 /* { dg-require-effective-target sse4 } */
4 /* { dg-skip-if "no M_PI" { vxworks_kernel } } */
6 #ifndef CHECK_H
7 #define CHECK_H "sse4_1-check.h"
8 #endif
10 #ifndef TEST
11 #define TEST sse4_1_test
12 #endif
14 #include CHECK_H
16 #include <math.h>
18 extern double floor (double);
20 #define NUM 64
22 static void
23 __attribute__((__target__("fpmath=sse")))
24 init_src (double *src)
26 int i, sign = 1;
27 double f = rand ();
29 for (i = 0; i < NUM; i++)
31 src[i] = (i + 1) * f * M_PI * sign;
32 if (i < (NUM / 2))
34 if ((i % 6) == 0)
35 f = f * src[i];
37 else if (i == (NUM / 2))
38 f = rand ();
39 else if ((i % 6) == 0)
40 f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
41 sign = -sign;
45 static void
46 __attribute__((__target__("fpmath=387")))
47 TEST (void)
49 double a[NUM];
50 int r[NUM];
51 int i;
53 init_src (a);
55 for (i = 0; i < NUM; i++)
56 r[i] = (int) floor (a[i]);
58 /* check results: */
59 for (i = 0; i < NUM; i++)
60 if (r[i] != (int) floor (a[i]))
61 abort();