2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-floor-sfix-vec-1.c
blobfab7e6528ae579e8d17e3663e1c79ae471bd1b13
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-skip-if "no M_PI" { vxworks_kernel } } */
6 #include <math.h>
7 #include "avx512f-check.h"
9 extern double floor (double);
11 #define NUM 64
13 static void
14 __attribute__((__target__("fpmath=sse")))
15 init_src (double *src)
17 int i, sign = 1;
18 double f = rand ();
20 for (i = 0; i < NUM; i++)
22 src[i] = (i + 1) * f * M_PI * sign;
23 if (i < (NUM / 2))
25 if ((i % 6) == 0)
26 f = f * src[i];
28 else if (i == (NUM / 2))
29 f = rand ();
30 else if ((i % 6) == 0)
31 f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
32 sign = -sign;
36 static void
37 __attribute__((__target__("fpmath=387")))
38 avx512f_test (void)
40 double a[NUM];
41 int r[NUM];
42 int i;
44 init_src (a);
46 for (i = 0; i < NUM; i++)
47 r[i] = (int) floor (a[i]);
49 /* check results: */
50 for (i = 0; i < NUM; i++)
51 if (r[i] != (int) floor (a[i]))
52 abort();