PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-mask-load-1.c
blob3a38b64e520fc2c25e2818f28093760eb50df5fd
1 /* { dg-additional-options "-Ofast -fno-common" } */
2 /* { dg-additional-options "-Ofast -fno-common -mavx" { target avx_runtime } } */
4 #include "tree-vect.h"
6 __attribute__((noinline, noclone)) void
7 foo (double *x, double *y)
9 double *p = __builtin_assume_aligned (x, 16);
10 double *q = __builtin_assume_aligned (y, 16);
11 double z, h;
12 int i;
13 for (i = 0; i < 1024; i++)
15 if (p[i] < 0.0)
16 z = q[i], h = q[i] * 7.0 + 3.0;
17 else
18 z = p[i] + 6.0, h = p[1024 + i];
19 p[i] = z + 2.0 * h;
23 double a[2048] __attribute__((aligned (16)));
24 double b[1024] __attribute__((aligned (16)));
26 int
27 main ()
29 int i;
30 check_vect ();
31 for (i = 0; i < 1024; i++)
33 a[i] = (i & 1) ? -i : 2 * i;
34 a[i + 1024] = i;
35 b[i] = 7 * i;
36 asm ("");
38 foo (a, b);
39 for (i = 0; i < 1024; i++)
40 if (a[i] != ((i & 1)
41 ? 7 * i + 2.0 * (7 * i * 7.0 + 3.0)
42 : 2 * i + 6.0 + 2.0 * i)
43 || b[i] != 7 * i
44 || a[i + 1024] != i)
45 abort ();
46 return 0;
49 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 1 "vect" { target avx_runtime } } } */