Merge from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-mask-load-1.c
blob2c30830bee2c88d5e9ed77a025c1bd7b6ac67aa3
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 (double *x, double *y)
11 double *p = __builtin_assume_aligned (x, 16);
12 double *q = __builtin_assume_aligned (y, 16);
13 double z, h;
14 int i;
15 for (i = 0; i < 1024; i++)
17 if (p[i] < 0.0)
18 z = q[i], h = q[i] * 7.0 + 3.0;
19 else
20 z = p[i] + 6.0, h = p[1024 + i];
21 p[i] = z + 2.0 * h;
25 double a[2048] __attribute__((aligned (16)));
26 double b[1024] __attribute__((aligned (16)));
28 int
29 main ()
31 int i;
32 check_vect ();
33 for (i = 0; i < 1024; i++)
35 a[i] = (i & 1) ? -i : 2 * i;
36 a[i + 1024] = i;
37 b[i] = 7 * i;
38 asm ("");
40 foo (a, b);
41 for (i = 0; i < 1024; i++)
42 if (a[i] != ((i & 1)
43 ? 7 * i + 2.0 * (7 * i * 7.0 + 3.0)
44 : 2 * i + 6.0 + 2.0 * i)
45 || b[i] != 7 * i
46 || a[i + 1024] != i)
47 abort ();
48 return 0;
51 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 1 "vect" { target avx_runtime } } } */
52 /* { dg-final { cleanup-tree-dump "vect" } } */