PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-i32gatherps256-4.c
blob07c2abacbf24cca9f5ed23fd29d49ee47ebee46a
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_i32gatherps256 (float *src,
10 float *s1, int *s2, float *mask, int scale, float *r)
12 int i;
14 for (i = 0; i < 8; ++i)
15 if ((((int *) mask)[i] >> 31) & 1)
16 r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
17 else
18 r[i] = src[i];
21 void static
22 avx2_test (void)
24 int i;
25 union256i_d idx;
26 union256 res, src, mask;
27 float s1[8], res_ref[8] = { 0 };
29 for (i = 0; i < 8; ++i)
31 /* Set some stuff */
32 s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
34 /* Set src as something different from s1 */
35 src.a[i] = -s1[i];
37 /* Mask out evens */
38 ((int *) mask.a)[i] = i % 2 ? 0 : -1;
40 /* About to gather in reverse order,
41 divide by 2 to demonstrate scale */
42 idx.a[i] = (32 - (i + 1) * 4) >> 1;
45 res.x = _mm256_mask_i32gather_ps (src.x, s1, idx.x, mask.x, 2);
47 compute_i32gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
49 if (check_union256 (res, res_ref) != 0)
50 abort ();