]> gcc.gnu.org Git - gcc.git/commit
Do not generate fmaddfp and fnmsubfp
authorMichael Meissner <meissner@linux.ibm.com>
Thu, 6 Apr 2023 20:31:58 +0000 (16:31 -0400)
committerMichael Meissner <meissner@linux.ibm.com>
Thu, 6 Apr 2023 20:31:58 +0000 (16:31 -0400)
commit80575f56b4392f1f0afe58ee0b1478e54d41a4ca
treec80927b3d459c1e9c809fc5c5bf183539b4ab6df
parent0fbec939e9eea2e4987badd3eed13d9b35fd68c2
Do not generate fmaddfp and fnmsubfp

The Altivec instructions fmaddfp and fnmsubfp have different rounding behaviors
than the VSX xvmaddsp and xvnmsubsp instructions.  In particular, generating
these instructions seems to break Eigen.

GCC has generated the Altivec fmaddfp and fnmsubfp instructions on VSX systems
as an alternative to the xsmadd{a,m}sp and xsnmsub{a,m}sp instructions.  The
advantage  of the Altivec instructions is that they are 4 operand instructions
(i.e. the target register does not have to overlap with one of the input
registers).  The advantage is it can eliminate an extra move instruction.  The
disadvantage is it does round the same was as the VSX instructions.

This patch eliminates the generation of the Altivec fmaddfp and fnmsubfp
instructions as alternatives in the VSX instruction insn support, and in the
Altivec insns it adds a test to prevent the insn from being used if VSX is
available.  I also added a test to the regression test suite.

I have done bootstrap builds on power9 little endian (with both IEEE long
double and IBM long double).  I have also done the builds and test on a power8
big endian system (testing both 32-bit and 64-bit code generation).  Chip has
verified that it fixes the problem that Eigen encountered.  Can I check this
into the master GCC branch?  After a burn-in period, can I check this patch
into the active GCC branches?

Thanks in advance.

2023-04-06   Michael Meissner  <meissner@linux.ibm.com>

gcc/

PR target/70243
* config/rs6000/rs6000.md (isa attribute): Add fastmath.
(enabled attribute): Add support for fastmath.
* config/rs6000/vsx.md (vsx_fmav4sf4): Set the isa attribute to
fastmath to disable Altivec instruction generatins normally.
(vsx_nfmsv4sf4): Likewise.

gcc/testsuite/

PR target/70243
* gcc.target/powerpc/pr70243.c: New test.
* gcc.target/powerpc/pr70243-2.c: New test.
gcc/config/rs6000/rs6000.md
gcc/config/rs6000/vsx.md
gcc/testsuite/gcc.target/powerpc/pr70243-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr70243.c [new file with mode: 0644]
This page took 0.061217 seconds and 6 git commands to generate.