This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Steve Ellcey <sellcey at imgtec dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, <clm at codesourcery dot com>, <matthew dot fortune at imgtec dot com>
- Date: Thu, 11 Jun 2015 20:11:56 +0000
- Subject: Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd
- Authentication-results: sourceware.org; auth=none
- References: <4c25620c-546c-40ae-b330-3652fe25f791 at BAMAIL02 dot ba dot imgtec dot org>
On Thu, 11 Jun 2015, Steve Ellcey wrote:
> loongson and r8000 have the most changes, they no longer generate msub
> instructions with -mfused-madd because that instruction does not generate
> the correct NAN in some cases (the sign may be wrong). If HONOR_NANS
> is not set then they will generate msub instructions.
There's no such thing as a correct NaN sign for fused multiply-add (at the
C / GIMPLE / RTL level, that is; there may be a correct sign at the level
of semantics for processor instructions). IEEE 754 only specifies signs
of NaNs for a few operations (copy, negate, abs, copySign). So while you
need to avoid negate / abs instructions that don't work properly on NaNs,
if signs of NaNs are the only concern then that's not a reason to avoid
any other arithmetic operations.
> One thing I did not put in this patch was to add code to use the
> mips32r6/mips64r6 msubf instruction. This instruction implements
> 'c - (a * b)', not '(a * b) - c' and since it not currently used by
> GCC I decided not to add it to this patch.
Fused c - (a * b) is exactly equivalent to fused (-a * b) + c or
(a * -b) + c (I don't know which is canonical in RTL). (It's *not*
equivalent to fused -((a * b) - c), when the result is an exact zero.
And moving negation inside multiplication like that is only valid for a
fused operation, not unfused if -frounding-math.)
--
Joseph S. Myers
joseph@codesourcery.com