On Thu, Sep 28, 2017 at 12:40:24AM +0000, Joseph Myers wrote:
> On Wed, 27 Sep 2017, Michael Meissner wrote:
>
> > The glibc team has requested we define the standard macro
> > (__FP_FAST_FMAF128)
> > for PowerPC code when we have the IEEE 128-bit floating point hardware
> > instructions enabled.
>
> It's not a standard macro. TS 18661-3 has FP_FAST_FMAF128 as an optional
> math.h macro (but glibc doesn't define it anywhere at present).
>
> > This patch does this in the PowerPC backend. As I look at the whole issue,
> > at
> > some point we should do this more in the machine independent portion of the
> > compiler. I have some initial patches to do this in the c-family files,
> > but at
> > the present time, the patches are not complete, and I need to think about it
> > more.
>
> I think a machine-independent definition (for _FloatN / _FloatNx types in
> general) should go along with machine-independent fmafN / fmafNx built-in
> functions; when the built-in function is machine-specific, it's natural
> for the macro to be as well.
>
> But in any case, the new macro should be documented in cpp.texi alongside
> the existing __FP_FAST_FMA* macros (probably in the generic
> __FP_FAST_FMAF@var{n} and __FP_FAST_FMAF@var{n}X form).
This patch adds support for adding the built-in __builtin_fmaf<N> and
__builtin_fmaf<N>x functions if the target machine supports an appropriate
fused multiply-add (FMA) instruction. This patch replaces the original PowerPC
specific patch.
Because it involves changes in the built-in support, both the c and c-family
subdirectories, as well as PowerPC changes, I added the global/release
maintainers to the To: list.
I have done a bootstrap and make check on a little endian Power8 with no
regresions in the tests. I have verified that the changed and new tests both
ran fine.
I have also bootstrapped the changes on an x86-64 compiler, and it bootstrapped
fine. I am currently running the unmodified build, but I'm not expecting any
changes in the test suite.
Assuming the x86-64 tests also have no regressions, can I check these changes
into the trunk?
[gcc]
2017-10-02 Michael Meissner <[email protected]>
* builtins.def (BUILT_IN_FMAF16): Add support for fused
multiply-add built-in functions for _Float<N> and _Float<N>x
types.
(BUILT_IN_FMAF32): Likewise.
(BUILT_IN_FMAF64): Likewise.
(BUILT_IN_FMAF128): Likewise.
(BUILT_IN_FMAF32X): Likewise.
(BUILT_IN_FMAF64X): Likewise.
(BUILT_IN_FMAF128X): Likewise.
* builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16):
Likewise.
(BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise.
(BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise.
(BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise.
(BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise.
(BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise.
(BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise.
* builtins.c (expand_builtin_mathfn_ternary): Likewise.
(expand_builtin): Add fused multiply-add builtin support for
_Float<N> and _Float<N>X types. Issue a warning if the machine
does not provide an appropriate FMA insn.
(fold_builtin_3): Add support for fused multiply-add built-in
functions for _Float<N> and _Float<N>x types.
* config/rs6000/rs6000-builtins.def (FMAF128): Delete creating
__builtin_fmaf128, since this is now done in machine independent
code.
* doc/cpp.texi (__FP_FAST_FMAF16): Document macros set to declare
that the appropriate fused multiply-add on _Float<N> and
_Float<N>X types is implemented.
(__FP_FAST_FMAF32): Likewise.
(__FP_FAST_FMAF64): Likewise.
(__FP_FAST_FMAF128): Likewise.
(__FP_FAST_FMAF32X): Likewise.
(__FP_FAST_FMAF64X): Likewise.
(__FP_FAST_FMAF128X): Likewise.
[gcc/c]
2017-10-02 Michael Meissner <[email protected]>
* c-decl.c (header_for_builtin_fn): Add support for fused
multiply-add built-in functions for _Float<N> and _Float<N>x
types.
[gcc/c-family]
2017-10-02 Michael Meissner <[email protected]>
* c-cppbuiltin.c (mode_has_fma): Add support for PowerPC _float128
FMA (KFmode) if long double != __float128.
(c_cpp_builtins): Define __FP_FAST_FMAF<N> if _Float<N> fused
multiply-add is supported. Define __FP_FAST_FMAF<N>X if
_Float<N>x fused multiply-add is supported.
[gcc/testsuite]
2017-10-02 Michael Meissner <[email protected]>
* gcc.target/powerpc/float128-fma2.c: Change error to new
warning.
* gcc.target/powerpc/float128-fma3.c: New test.
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: [email protected], phone: +1 (978) 899-4797