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.
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. So, I would like to check in this patch now, and if we come up with a machine independent version, we can back out this particular patch. I have done a full bootstrap and regression test, there were no regressions, and the new test case does run correctly. Can I check this into the trunk? [gcc] 2017-09-27 Michael Meissner <meiss...@linux.vnet.ibm.com> * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define __FP_FAST_FMAF128 on ISA 3.0. [gcc/testsuite] 2017-09-27 Michael Meissner <meiss...@linux.vnet.ibm.com> * gcc.target/powerpc/float128-fma3.c: New test. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/rs6000-c.c =================================================================== --- gcc/config/rs6000/rs6000-c.c (revision 253236) +++ gcc/config/rs6000/rs6000-c.c (working copy) @@ -585,7 +585,10 @@ rs6000_target_modify_macros (bool define /* OPTION_MASK_FLOAT128_HARDWARE can be turned on if -mcpu=power9 is used or via the target attribute/pragma. */ if ((flags & OPTION_MASK_FLOAT128_HW) != 0) - rs6000_define_or_undefine_macro (define_p, "__FLOAT128_HARDWARE__"); + { + rs6000_define_or_undefine_macro (define_p, "__FLOAT128_HARDWARE__"); + rs6000_define_or_undefine_macro (define_p, "__FP_FAST_FMAF128"); + } /* options from the builtin masks. */ /* Note that RS6000_BTM_PAIRED is enabled only if Index: gcc/testsuite/gcc.target/powerpc/float128-fma3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/float128-fma3.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/float128-fma3.c (working copy) @@ -0,0 +1,33 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-mpower9-vector -O2" } */ + +/* Make sure the appropriate FMA fast macros are defined. */ + +#ifdef __FP_FAST_FMAF +float +do_fmaf (float a, float b, float c) +{ + return __builtin_fmaf (a, b, c); +} +#endif + +#ifdef __FP_FAST_FMA +double +do_fma (double a, double b, double c) +{ + return __builtin_fma (a, b, c); +} +#endif + +#ifdef __FP_FAST_FMAF128 +_Float128 +do_fmaf128 (_Float128 a, _Float128 b, _Float128 c) +{ + return __builtin_fmaf128 (a, b, c); +} +#endif + +/* { dg-final { scan-assembler {\mfmadds\M|\mxsmadd.sp\M} } } */ +/* { dg-final { scan-assembler {\mfmadd\M|\mxsmadd.dp\M} } } */ +/* { dg-final { scan-assembler {\mxsmaddqp\M} } } */