Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512dq-vrangeps-2.c
blob373260abd79be90022af745563694fe9b3297da4
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512dq -DAVX512DQ" } */
3 /* { dg-require-effective-target avx512dq } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 32)
8 #include "avx512f-mask-type.h"
9 #define IMM 0x02
11 void
12 CALC (float *s1, float *s2, float *r)
14 int i;
16 for (i = 0; i < SIZE; i++)
18 if (s1[i] < -s2[i])
19 r[i] = -s2[i];
20 else if (s1[i] > s2[i])
21 r[i] = s2[i];
22 else
23 r[i] = s1[i];
27 void
28 TEST (void)
30 UNION_TYPE (AVX512F_LEN, ) s1, s2, res1, res2, res3;
31 MASK_TYPE mask = MASK_VALUE;
32 float res_ref[SIZE];
33 int i, sign = 1;
35 for (i = 0; i < SIZE; i++)
37 s1.a[i] = 234.567 * i * sign;
38 s2.a[i] = 100 * (i + 1);
39 res2.a[i] = DEFAULT_VALUE;
40 sign = -sign;
43 res1.x = INTRINSIC (_range_ps) (s1.x, s2.x, IMM);
44 res2.x = INTRINSIC (_mask_range_ps) (res2.x, mask, s1.x, s2.x, IMM);
45 res3.x = INTRINSIC (_maskz_range_ps) (mask, s1.x, s2.x, IMM);
47 CALC (s1.a, s2.a, res_ref);
49 if (UNION_CHECK (AVX512F_LEN, ) (res1, res_ref))
50 abort ();
52 MASK_MERGE () (res_ref, mask, SIZE);
53 if (UNION_CHECK (AVX512F_LEN, ) (res2, res_ref))
54 abort ();
56 MASK_ZERO () (res_ref, mask, SIZE);
57 if (UNION_CHECK (AVX512F_LEN, ) (res3, res_ref))
58 abort ();