Stop only if there aren't any usable algorithms
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vrndscalesd-2.c
blobb96aa462790e31107d2b34c48ab42bf67e61ea7a
1 /* { dg-do run } */
2 /* { dg-options "-mavx512f -O2" } */
3 /* { dg-require-effective-target avx512f } */
5 #define SIZE (128 / 64)
7 #include <math.h>
8 #include "avx512f-check.h"
10 static void
11 compute_rndscalesd (double *s1, double *s2, double *r, int imm)
13 int rc, m;
14 rc = imm & 0xf;
15 m = imm >> 4;
17 switch (rc)
19 case _MM_FROUND_FLOOR:
20 r[0] = floor (s2[0] * pow (2, m)) / pow (2, m);
21 break;
22 case _MM_FROUND_CEIL:
23 r[0] = ceil (s2[0] * pow (2, m)) / pow (2, m);
24 break;
25 default:
26 abort ();
27 break;
30 r[1] = s1[1];
33 static void
34 avx512f_test (void)
36 int imm = _MM_FROUND_FLOOR | (7 << 4);
37 union128d s1, s2, res1;
38 double res_ref[SIZE];
40 s1.x = _mm_set_pd (4.05084, -1.23162);
41 s2.x = _mm_set_pd (-3.53222, 7.33527);
43 res1.x = _mm_roundscale_sd (s1.x, s2.x, imm);
45 compute_rndscalesd (s1.a, s2.a, res_ref, imm);
47 if (check_union128d (res1, res_ref))
48 abort ();