Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vrndscaleps-2.c
blob25f385c31df638a79f10373297f483c36bb4f6dd
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
5 #define AVX512F
7 #include "avx512f-helper.h"
9 #define SIZE (AVX512F_LEN / 32)
10 #include "avx512f-mask-type.h"
11 #include "math.h"
13 static void
14 CALC (float *s, float *r, int imm)
16 int i = 0, rc, m;
17 rc = imm & 0xf;
18 m = imm >> 4;
19 for (i = 0; i < SIZE; i++)
20 switch (rc)
22 case _MM_FROUND_FLOOR:
23 r[i] = floor (s[i] * pow (2, m)) / pow (2, m);
24 break;
25 case _MM_FROUND_CEIL:
26 r[i] = ceil (s[i] * pow (2, m)) / pow (2, m);
27 break;
28 default:
29 abort ();
30 break;
34 void
35 TEST (void)
37 int imm, i, j;
38 UNION_TYPE (AVX512F_LEN,) res1, res2, res3, s;
39 float res_ref[SIZE];
41 MASK_TYPE mask = MASK_VALUE;
43 imm = _MM_FROUND_FLOOR | (7 << 4);
45 for (i = 0; i < 3; i++)
48 for (j = 0; j < SIZE; j++)
50 s.a[j] = j * (j + 12.0231);
51 res1.a[j] = DEFAULT_VALUE;
52 res2.a[j] = DEFAULT_VALUE;
53 res3.a[j] = DEFAULT_VALUE;
56 switch (i)
58 case 0:
59 imm = _MM_FROUND_FLOOR | (7 << 4);
60 res1.x = INTRINSIC (_roundscale_ps) (s.x, imm);
61 res2.x = INTRINSIC (_mask_roundscale_ps) (res2.x, mask, s.x, imm);
62 res3.x = INTRINSIC (_maskz_roundscale_ps) (mask, s.x, imm);
63 break;
64 case 1:
65 imm = _MM_FROUND_FLOOR;
66 res1.x = INTRINSIC (_floor_ps) (s.x);
67 res2.x = INTRINSIC (_mask_floor_ps) (res2.x, mask, s.x);
68 break;
69 case 2:
70 imm = _MM_FROUND_CEIL;
71 res1.x = INTRINSIC (_ceil_ps) (s.x);
72 res2.x = INTRINSIC (_mask_ceil_ps) (res2.x, mask, s.x);
73 break;
76 CALC (s.a, res_ref, imm);
78 if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
79 abort ();
81 MASK_MERGE ()(res_ref, mask, SIZE);
83 if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
84 abort ();
86 MASK_ZERO ()(res_ref, mask, SIZE);
88 if (!i && UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
89 abort ();