2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-mask-loadstore-1.c
blob56b130e8bf739d27b62068d322798cd0f97d89e5
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 (float *__restrict x, float *__restrict y, float *__restrict z)
9 float *__restrict p = __builtin_assume_aligned (x, 32);
10 float *__restrict q = __builtin_assume_aligned (y, 32);
11 float *__restrict r = __builtin_assume_aligned (z, 32);
12 int i;
13 for (i = 0; i < 1024; i++)
15 if (p[i] < 0.0f)
16 q[i] = p[i] + 2.0f;
17 else
18 p[i] = r[i] + 3.0f;
22 float a[1024] __attribute__((aligned (32)));
23 float b[1024] __attribute__((aligned (32)));
24 float c[1024] __attribute__((aligned (32)));
26 int
27 main ()
29 int i;
30 check_vect ();
31 for (i = 0; i < 1024; i++)
33 a[i] = (i & 1) ? -i : i;
34 b[i] = 7 * i;
35 c[i] = a[i] - 3.0f;
36 asm ("");
38 foo (a, b, c);
39 for (i = 0; i < 1024; i++)
40 if (a[i] != ((i & 1) ? -i : i)
41 || b[i] != ((i & 1) ? a[i] + 2.0f : 7 * i)
42 || c[i] != a[i] - 3.0f)
43 abort ();
44 return 0;
47 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 1 "vect" { target avx_runtime } } } */