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 jos...@codesourcery.com