libstdc++: Check feature test macros in unordered containers
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-i64gatherps256-4.c
blob8185cd839c9950266c4d9ce856fb23564610130f
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O2 -mavx2" } */
5 #include <string.h>
6 #include "avx2-check.h"
8 static void
9 compute_i64gatherps256 (float *src,
10 float *s1,
11 long long *s2, float *mask, int scale, float *r)
13 int i;
15 for (i = 0; i < 4; ++i)
16 if ((((int *) mask)[i] >> 31) & 1)
17 r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
18 else
19 r[i] = src[i];
22 void static
23 avx2_test (void)
25 int i;
26 union256i_q idx;
27 union128 res, src, mask;
28 float s1[4], res_ref[4] = { 0 };
30 for (i = 0; i < 4; ++i)
32 /* Set some stuff */
33 s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
35 /* Set src as something different from s1 */
36 src.a[i] = -s1[i];
38 /* Mask out evens */
39 ((int *) mask.a)[i] = i % 2 ? 0 : -1;
41 /* About to gather in reverse order,
42 divide by 2 to demonstrate scale */
43 idx.a[i] = (16 - (i + 1) * 4) >> 1;
46 res.x = _mm256_mask_i64gather_ps (src.x, s1, idx.x, mask.x, 2);
48 compute_i64gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
50 if (check_union128 (res, res_ref) != 0)
51 abort ();