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