1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-require-effective-target powerpc_vsx_ok } */
4 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
5 /* { dg-options "-O3 -ftree-vectorize -mcpu=power7 -ffast-math" } */
6 /* { dg-final { scan-assembler-times "xvmadd" 4 } } */
7 /* { dg-final { scan-assembler-times "xsmadd\|fmadd\ " 2 } } */
8 /* { dg-final { scan-assembler-times "fmadds" 2 } } */
9 /* { dg-final { scan-assembler-times "xvmsub" 2 } } */
10 /* { dg-final { scan-assembler-times "xsmsub\|fmsub\ " 1 } } */
11 /* { dg-final { scan-assembler-times "fmsubs" 1 } } */
12 /* { dg-final { scan-assembler-times "xvnmadd" 2 } } */
13 /* { dg-final { scan-assembler-times "xsnmadd\|fnmadd " 1 } } */
14 /* { dg-final { scan-assembler-times "fnmadds" 1 } } */
15 /* { dg-final { scan-assembler-times "xvnmsub" 2 } } */
16 /* { dg-final { scan-assembler-times "xsnmsub\|fnmsub " 1 } } */
17 /* { dg-final { scan-assembler-times "fnmsubs" 1 } } */
19 /* All functions should generate an appropriate (a * b) + c instruction
20 since -mfused-madd is on by default. */
23 builtin_fma (double b
, double c
, double d
)
25 return __builtin_fma (b
, c
, d
); /* xsmadd{a,m}dp */
29 builtin_fms (double b
, double c
, double d
)
31 return __builtin_fma (b
, c
, -d
); /* xsmsub{a,b}dp */
35 builtin_fnma (double b
, double c
, double d
)
37 return - __builtin_fma (b
, c
, d
); /* xsnmadd{a,b}dp */
41 builtin_fnms (double b
, double c
, double d
)
43 return - __builtin_fma (b
, c
, -d
); /* xsnmsub{a,b}dp */
47 builtin_fmaf (float b
, float c
, float d
)
49 return __builtin_fmaf (b
, c
, d
); /* fmadds */
53 builtin_fmsf (float b
, float c
, float d
)
55 return __builtin_fmaf (b
, c
, -d
); /* fmsubs */
59 builtin_fnmaf (float b
, float c
, float d
)
61 return - __builtin_fmaf (b
, c
, d
); /* fnmadds */
65 builtin_fnmsf (float b
, float c
, float d
)
67 return - __builtin_fmaf (b
, c
, -d
); /* fnmsubs */
71 normal_fma (double b
, double c
, double d
)
73 return (b
* c
) + d
; /* xsmadd{a,m}dp */
77 normal_fmaf (float b
, float c
, float d
)
79 return (b
* c
) + d
; /* fmadds */
86 double vda
[SIZE
] __attribute__((__aligned__(32)));
87 double vdb
[SIZE
] __attribute__((__aligned__(32)));
88 double vdc
[SIZE
] __attribute__((__aligned__(32)));
89 double vdd
[SIZE
] __attribute__((__aligned__(32)));
91 float vfa
[SIZE
] __attribute__((__aligned__(32)));
92 float vfb
[SIZE
] __attribute__((__aligned__(32)));
93 float vfc
[SIZE
] __attribute__((__aligned__(32)));
94 float vfd
[SIZE
] __attribute__((__aligned__(32)));
101 for (i
= 0; i
< SIZE
; i
++)
102 vda
[i
] = __builtin_fma (vdb
[i
], vdc
[i
], vdd
[i
]); /* xvmadd{a,m}dp */
110 for (i
= 0; i
< SIZE
; i
++)
111 vda
[i
] = __builtin_fma (vdb
[i
], vdc
[i
], -vdd
[i
]); /* xvmsub{a,m}dp */
119 for (i
= 0; i
< SIZE
; i
++)
120 vda
[i
] = - __builtin_fma (vdb
[i
], vdc
[i
], vdd
[i
]); /* xvnmadd{a,m}dp */
128 for (i
= 0; i
< SIZE
; i
++)
129 vda
[i
] = - __builtin_fma (vdb
[i
], vdc
[i
], -vdd
[i
]); /* xvnmsub{a,m}dp */
137 for (i
= 0; i
< SIZE
; i
++)
138 vfa
[i
] = __builtin_fmaf (vfb
[i
], vfc
[i
], vfd
[i
]); /* xvmadd{a,m}sp */
146 for (i
= 0; i
< SIZE
; i
++)
147 vfa
[i
] = __builtin_fmaf (vfb
[i
], vfc
[i
], -vfd
[i
]); /* xvmsub{a,m}sp */
155 for (i
= 0; i
< SIZE
; i
++)
156 vfa
[i
] = - __builtin_fmaf (vfb
[i
], vfc
[i
], vfd
[i
]); /* xvnmadd{a,m}sp */
164 for (i
= 0; i
< SIZE
; i
++)
165 vfa
[i
] = - __builtin_fmaf (vfb
[i
], vfc
[i
], -vfd
[i
]); /* xvnmsub{a,m}sp */
173 for (i
= 0; i
< SIZE
; i
++)
174 vda
[i
] = (vdb
[i
] * vdc
[i
]) + vdd
[i
]; /* xvmadd{a,m}dp */
182 for (i
= 0; i
< SIZE
; i
++)
183 vfa
[i
] = (vfb
[i
] * vfc
[i
]) + vfd
[i
]; /* xvmadd{a,m}sp */