1 /* { dg-additional-options "-Ofast -fno-common" } */
2 /* { dg-additional-options "-Ofast -fno-common -mavx" { target avx_runtime } } */
3
4 #include "tree-vect.h"
5
6 __attribute__((noinline, noclone)) void
foo(float * __restrict x,float * __restrict y,float * __restrict z)7 foo (float *__restrict x, float *__restrict y, float *__restrict z)
8 {
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++)
14 {
15 if (p[i] < 0.0f)
16 q[i] = p[i] + 2.0f;
17 else
18 p[i] = r[i] + 3.0f;
19 }
20 }
21
22 float a[1024] __attribute__((aligned (32)));
23 float b[1024] __attribute__((aligned (32)));
24 float c[1024] __attribute__((aligned (32)));
25
26 int
main()27 main ()
28 {
29 int i;
30 check_vect ();
31 for (i = 0; i < 1024; i++)
32 {
33 a[i] = (i & 1) ? -i : i;
34 b[i] = 7 * i;
35 c[i] = a[i] - 3.0f;
36 asm ("");
37 }
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;
45 }
46
47 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 1 "vect" { target avx_runtime } } } */
48