PR rtl-optimization/87918
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vsqrtsd-2.c
blob49ca7eea39fe949740aca41c6ef8e2dba3d87214
1 /* { dg-do run } */
2 /* { dg-options "-mavx512f -O2" } */
3 /* { dg-require-effective-target avx512f } */
5 #include <math.h>
6 #include "avx512f-check.h"
8 #define SIZE (128 / 64)
9 #include "avx512f-mask-type.h"
11 static void
12 compute_sqrtsd (double *s1, double *s2, double *r)
14 r[0] = sqrt(s2[0]);
15 r[1] = s1[1];
18 void static
19 avx512f_test (void)
21 union128d res1, res2, res3;
22 union128d s1, s2;
23 double res_ref[SIZE];
24 MASK_TYPE mask = MASK_VALUE;
25 int i;
27 for (i = 0; i < SIZE; i++)
29 s1.a[i] = 11.5 * (i + 1);
30 s2.a[i] = 10.5 * (i + 1);
31 res_ref[i] = 9.5 * (i + 1);
32 res1.a[i] = DEFAULT_VALUE;
33 res2.a[i] = DEFAULT_VALUE;
34 res3.a[i] = DEFAULT_VALUE;
37 res1.x = _mm_sqrt_round_sd (s1.x, s2.x,
38 _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
39 res2.x = _mm_mask_sqrt_round_sd (s1.x, mask, s1.x, s2.x,
40 _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
41 res3.x = _mm_maskz_sqrt_round_sd (mask, s1.x, s2.x,
42 _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
44 compute_sqrtsd (s1.a, s2.a, res_ref);
46 if (check_union128d (res1, res_ref))
47 abort ();
49 MASK_MERGE (d) (res_ref, mask, 1);
51 if (check_union128d (res2, res_ref))
52 abort ();
54 MASK_ZERO (d) (res_ref, mask, 1);
56 if (check_union128d (res3, res_ref))
57 abort ();