1 /* { dg-require-effective-target scalar_all_fma } */
2
3 #include "tree-vect.h"
4
5 #define N (VECTOR_BITS * 11 / 64 + 3)
6
7 #define DEF(INV) \
8 void __attribute__ ((noipa)) \
9 f_##INV (double *restrict a, double *restrict b, \
10 double *restrict c, double *restrict d) \
11 { \
12 for (int i = 0; i < N; ++i) \
13 { \
14 double mb = (INV & 1 ? -b[i] : b[i]); \
15 double mc = c[i]; \
16 double md = (INV & 2 ? -d[i] : d[i]); \
17 double fma = __builtin_fma (mb, mc, md); \
18 a[i] = (INV & 4 ? -fma : fma); \
19 } \
20 }
21
22 #define TEST(INV) \
23 { \
24 f_##INV (a, b, c, d); \
25 for (int i = 0; i < N; ++i) \
26 { \
27 double mb = (INV & 1 ? -b[i] : b[i]); \
28 double mc = c[i]; \
29 double md = (INV & 2 ? -d[i] : d[i]); \
30 double fma = __builtin_fma (mb, mc, md); \
31 double expected = (INV & 4 ? -fma : fma); \
32 if (a[i] != expected) \
33 __builtin_abort (); \
34 asm volatile ("" ::: "memory"); \
35 } \
36 }
37
38 #define FOR_EACH_INV(T) \
39 T (0) T (1) T (2) T (3) T (4) T (5) T (6) T (7)
40
FOR_EACH_INV(DEF)41 FOR_EACH_INV (DEF)
42
43 int
44 main (void)
45 {
46 double a[N], b[N], c[N], d[N];
47 for (int i = 0; i < N; ++i)
48 {
49 b[i] = i % 17;
50 c[i] = i % 9 + 11;
51 d[i] = i % 13 + 14;
52 asm volatile ("" ::: "memory");
53 }
54 FOR_EACH_INV (TEST)
55 return 0;
56 }
57
58 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 8 "vect" { target vect_double } } } */
59