1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f -std=gnu99" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target c99_runtime } */
5 
6 #define AVX512F
7 
8 #include "avx512f-helper.h"
9 
10 #define SIZE (AVX512F_LEN / 32)
11 #include "avx512f-mask-type.h"
12 #include "math.h"
13 #include "float.h"
14 
15 static void
CALC(float * r,float src,int tbl)16 CALC (float *r, float src, int tbl)
17 {
18   switch (tbl & 0xf)
19     {
20     case 0:
21       *r = src;
22       break;
23     case 1:
24       *r = src;
25       break;
26     case 2:
27       *r = signbit (src) ? -NAN : NAN;
28       break;
29     case 3:
30       *r = -NAN;
31       break;
32     case 4:
33       *r = -INFINITY;
34       break;
35     case 5:
36       *r = INFINITY;
37       break;
38     case 6:
39       *r = signbit (src) ? -INFINITY : INFINITY;
40       break;
41     case 7:
42       *r = 1.0 / -INFINITY;
43       break;
44     case 8:
45       *r = 0.0;
46       break;
47     case 9:
48       *r = -1.0;
49       break;
50     case 10:
51       *r = 1.0;
52       break;
53     case 11:
54       *r = 1.0 / 2.0;
55       break;
56     case 12:
57       *r = 90.0;
58       break;
59     case 13:
60       *r = M_PI_2;
61       break;
62     case 14:
63       *r = FLT_MAX;
64       break;
65     case 15:
66       *r = -FLT_MAX;
67       break;
68     default:
69       abort ();
70     }
71 }
72 
73 
74 void
TEST(void)75 TEST (void)
76 {
77   int i, j;
78   UNION_TYPE (AVX512F_LEN,) res1, res2, res3, s1;
79   UNION_TYPE (AVX512F_LEN, i_d) s2;
80   float res_ref[SIZE];
81 
82 
83   float vals[2] = { -10, 10 };
84   int controls[16] = { 0x11111111,
85     0x77777777, 0x88888888, 0x99999999,
86     0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc,
87     0x77777777, 0x88888888, 0x99999999,
88     0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc,
89     0xdddddddd, 0xeeeeeeee, 0xffffffff
90   };
91 
92   MASK_TYPE mask = MASK_VALUE;
93 
94   for (i = 0; i < 2; i++)
95     {
96       for (j = 0; j < SIZE; j++)
97 	{
98 	  s1.a[j] = vals[i];
99 	  s2.a[j] = controls[j];
100 	  res1.a[j] = DEFAULT_VALUE;
101 	  res2.a[j] = DEFAULT_VALUE;
102 	  res3.a[j] = DEFAULT_VALUE;
103 
104 	  CALC (&res_ref[j], s1.a[j], s2.a[j]);
105 	}
106 
107       res1.x = INTRINSIC (_fixupimm_ps) (res1.x, s1.x, s2.x, 0);
108       res2.x = INTRINSIC (_mask_fixupimm_ps) (res2.x, mask, s1.x, s2.x, 0);
109       res3.x = INTRINSIC (_maskz_fixupimm_ps) (mask, res3.x, s1.x, s2.x, 0);
110 
111       if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
112 	abort ();
113 
114       MASK_MERGE() (res_ref, mask, SIZE);
115       if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
116 	abort ();
117       MASK_ZERO() (res_ref, mask, SIZE);
118       if (UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
119 	abort ();
120     }
121 }
122 
123