libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / fast-math-vect-call-1.c
blob6c9b7c37b6ec4aae79402d1a97f800ab310753e3
1 /* Disabling epilogues until we find a better way to deal with scans. */
2 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
3 #include "tree-vect.h"
5 extern float copysignf (float, float);
6 extern float sqrtf (float);
7 extern float fabsf (float);
8 extern void abort (void);
9 float a[64], b[64], c[64], d[64];
11 __attribute__((noinline, noclone)) void
12 f1 (int n)
14 int i;
15 for (i = 0; i < n; i++)
17 a[4 * i + 0] = copysignf (b[4 * i + 0], c[4 * i + 0]) + 1.0f + sqrtf (d[4 * i + 0]);
18 a[4 * i + 1] = copysignf (b[4 * i + 1], c[4 * i + 1]) + 2.0f + sqrtf (d[4 * i + 1]);
19 a[4 * i + 2] = copysignf (b[4 * i + 2], c[4 * i + 2]) + 3.0f + sqrtf (d[4 * i + 2]);
20 a[4 * i + 3] = copysignf (b[4 * i + 3], c[4 * i + 3]) + 4.0f + sqrtf (d[4 * i + 3]);
24 __attribute__((noinline, noclone)) void
25 f2 (int n)
27 int i;
28 for (i = 0; i < 2 * n; i++)
30 a[2 * i + 0] = copysignf (b[2 * i + 0], c[2 * i + 0]) + 1.0f + sqrtf (d[2 * i + 0]);
31 a[2 * i + 1] = copysignf (b[2 * i + 1], c[2 * i + 1]) + 2.0f + sqrtf (d[2 * i + 1]);
35 __attribute__((noinline, noclone)) void
36 f3 (void)
38 int i;
39 for (i = 0; i < 64; i++)
40 a[i] = copysignf (b[i], c[i]) + 1.0f + sqrtf (d[i]);
43 __attribute__((noinline, noclone)) void
44 f4 (int n)
46 int i;
47 for (i = 0; i < 2 * n; i++)
49 a[3 * i + 0] = copysignf (b[3 * i + 0], c[3 * i + 0]) + 1.0f + sqrtf (d[3 * i + 0]);
50 a[3 * i + 1] = copysignf (b[3 * i + 1], c[3 * i + 1]) + 2.0f + sqrtf (d[3 * i + 1]);
51 a[3 * i + 2] = copysignf (b[3 * i + 2], c[3 * i + 2]) + 3.0f + sqrtf (d[3 * i + 2]);
55 __attribute__((noinline, noclone)) int
56 main1 ()
58 int i;
60 for (i = 0; i < 64; i++)
62 asm ("");
63 b[i] = (i & 1) ? -4 * i : 4 * i;
64 c[i] = (i & 2) ? -8 * i : 8 * i;
65 d[i] = i * i;
67 f1 (16);
68 #pragma GCC novector
69 for (i = 0; i < 64; i++)
70 if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i & 3) + i - a[i]) >= 0.0001f)
71 abort ();
72 else
73 a[i] = 131.25;
74 f2 (16);
75 #pragma GCC novector
76 for (i = 0; i < 64; i++)
77 if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i & 1) + i - a[i]) >= 0.0001f)
78 abort ();
79 else
80 a[i] = 131.25;
81 f3 ();
82 #pragma GCC novector
83 for (i = 0; i < 64; i++)
84 if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + i - a[i]) >= 0.0001f)
85 abort ();
86 else
87 a[i] = 131.25;
88 f4 (10);
89 #pragma GCC novector
90 for (i = 0; i < 60; i++)
91 if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i % 3) + i - a[i]) >= 0.0001f)
92 abort ();
93 return 0;
96 int
97 main ()
99 check_vect ();
100 return main1 ();
103 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" { target { vect_call_copysignf && vect_call_sqrtf } } } } */
104 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { { vect_call_copysignf && vect_call_sqrtf } && vect_perm3_int } } } } */