PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-gather-4.c
blob104b9c2d4900a14c3b90f42d1dd3e36b7af5cd9e
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O3 -mavx2 -mtune=skylake" } */
5 #include "avx2-check.h"
7 #define N 1024
8 int a[N], b[N], c[N], d[N];
10 __attribute__((noinline, noclone)) void
11 foo (float *__restrict p, float *__restrict q, float *__restrict r,
12 long s1, long s2, long s3)
14 int i;
15 for (i = 0; i < N; i++)
16 p[i] = q[a[i] * s1 + b[i] * s2 + s3] * r[c[i] * s1 + d[i] * s2 + s3];
19 static void
20 avx2_test (void)
22 int i;
23 float e[N], f[N], g[N];
24 for (i = 0; i < N; i++)
26 a[i] = (i * 7) & (N / 8 - 1);
27 b[i] = (i * 13) & (N / 8 - 1);
28 c[i] = (i * 23) & (N / 8 - 1);
29 d[i] = (i * 5) & (N / 8 - 1);
30 e[i] = 16.5 + i;
31 f[i] = 127.5 - i;
33 foo (g, e, f, 3, 2, 4);
34 for (i = 0; i < N; i++)
35 if (g[i] != (float) ((20.5 + a[i] * 3 + b[i] * 2)
36 * (123.5 - c[i] * 3 - d[i] * 2)))
37 abort ();