PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-i32gatherps-2.c
blob1174ddad5166f86cee457af29de5d61c829cef08
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_i32gatherps (float *s1, int *s2, int scale, float *r)
11 int i;
13 for (i = 0; i < 4; ++i)
14 r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
17 void static
18 avx2_test (void)
20 int i;
21 union128i_d idx;
22 union128 res;
23 float s1[4], res_ref[4] = { 0 };
25 for (i = 0; i < 4; ++i)
27 /* Set some stuff */
28 s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
30 /* About to gather in reverse order,
31 divide by 2 to demonstrate scale */
32 idx.a[i] = (16 - (i + 1) * 4) >> 1;
35 res.x = _mm_i32gather_ps (s1, idx.x, 2);
37 compute_i32gatherps (s1, idx.a, 2, res_ref);
39 if (check_union128 (res, res_ref) != 0)
40 abort ();