Rebase.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vfixupimmpd-2.c
blob3f338b9e90d1c050dde93e715cb2e75db882f9e7
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f -std=gnu99" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target c99_runtime } */
6 #define AVX512F
8 #include "avx512f-helper.h"
10 #define SIZE (AVX512F_LEN / 64)
11 #include "avx512f-mask-type.h"
12 #include "math.h"
13 #include "values.h"
15 static void
16 CALC (double *r, double src, long long tbl)
18 switch (tbl & 0xf)
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 = MAXDOUBLE;
64 break;
65 case 15:
66 *r = -MAXDOUBLE;
67 break;
68 default:
69 abort ();
73 void
74 TEST (void)
76 int i, j;
77 UNION_TYPE (AVX512F_LEN, d) res1, res2, res3, s1;
78 UNION_TYPE (AVX512F_LEN, i_q) s2;
79 double res_ref[SIZE];
82 float vals[2] = { -10, 10 };
83 int controls[8] = {0x11111111, 0x77777777, 0x77777777, 0x88888888,
84 0x99999999, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc};
86 MASK_TYPE mask = MASK_VALUE;
88 for (i = 0; i < 2; i++)
90 for (j = 0; j < SIZE; j++)
92 s1.a[j] = vals[i];
93 s2.a[j] = controls[j];
94 res1.a[j] = DEFAULT_VALUE;
95 res2.a[j] = DEFAULT_VALUE;
96 res3.a[j] = DEFAULT_VALUE;
98 CALC (&res_ref[j], s1.a[j], s2.a[j]);
101 res1.x = INTRINSIC (_fixupimm_pd) (res1.x, s1.x, s2.x, 0);
102 res2.x = INTRINSIC (_mask_fixupimm_pd) (res2.x, mask, s1.x, s2.x, 0);
103 res3.x = INTRINSIC (_maskz_fixupimm_pd) (mask, res3.x, s1.x, s2.x, 0);
105 if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref))
106 abort ();
108 MASK_MERGE(d) (res_ref, mask, SIZE);
109 if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref))
110 abort ();
111 MASK_ZERO(d) (res_ref, mask, SIZE);
112 if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref))
113 abort ();