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