Stop only if there aren't any usable algorithms
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-i32gatherpd256-4.c
blobf24acbd7fe15c030b1b09913bf10b7aedb976a6e
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_i32gatherpd256 (double *src,
10 double *s1,
11 int *s2, double *mask, int scale, double *r)
13 int i;
15 for (i = 0; i < 4; ++i)
16 if ((((long long *) mask)[i] >> 63) & 1)
17 r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
18 else
19 r[i] = src[i];
22 void static
23 avx2_test (void)
25 int i;
26 union128i_d idx;
27 union256d res, src, mask;
28 double 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 ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
41 /* About to gather in reverse order, divide by 2
42 to demonstrate scale */
43 idx.a[i] = (16 - (i + 1) * 8) >> 1;
46 res.x = _mm256_mask_i32gather_pd (src.x, s1, idx.x, mask.x, 2);
48 compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
50 if (check_union256d (res, res_ref) != 0)
51 abort ();