Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / gcc.dg / vect / vect-mask-loadstore-1.c
blobecc164fe1ff64f3f442dd2fe44a609a215c8aa16
1 /* { dg-do run } */
2 /* { dg-additional-options "-Ofast -fno-common" } */
3 /* { dg-additional-options "-Ofast -fno-common -mavx" { target avx_runtime } } */
5 #include <stdlib.h>
6 #include "tree-vect.h"
8 __attribute__((noinline, noclone)) void
9 foo (float *__restrict x, float *__restrict y, float *__restrict z)
11 float *__restrict p = __builtin_assume_aligned (x, 32);
12 float *__restrict q = __builtin_assume_aligned (y, 32);
13 float *__restrict r = __builtin_assume_aligned (z, 32);
14 int i;
15 for (i = 0; i < 1024; i++)
17 if (p[i] < 0.0f)
18 q[i] = p[i] + 2.0f;
19 else
20 p[i] = r[i] + 3.0f;
24 float a[1024] __attribute__((aligned (32)));
25 float b[1024] __attribute__((aligned (32)));
26 float c[1024] __attribute__((aligned (32)));
28 int
29 main ()
31 int i;
32 check_vect ();
33 for (i = 0; i < 1024; i++)
35 a[i] = (i & 1) ? -i : i;
36 b[i] = 7 * i;
37 c[i] = a[i] - 3.0f;
38 asm ("");
40 foo (a, b, c);
41 for (i = 0; i < 1024; i++)
42 if (a[i] != ((i & 1) ? -i : i)
43 || b[i] != ((i & 1) ? a[i] + 2.0f : 7 * i)
44 || c[i] != a[i] - 3.0f)
45 abort ();
46 return 0;
49 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 1 "vect" { target avx_runtime } } } */
50 /* { dg-final { cleanup-tree-dump "vect" } } */