On Tue, Nov 08, 2022 at 09:44:40AM -0800, Andrew Waterman wrote: > On Tue, Nov 8, 2022 at 3:20 AM Jakub Jelinek via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > On Mon, Nov 07, 2022 at 04:41:23PM +0100, Aldy Hernandez wrote: > > > As suggested upthread, I have also adjusted update_nan_sign() to drop > > > the NAN sign to VARYING if both operands are NAN. As an optimization > > > I keep the sign if both operands are NAN and have the same sign. > > > > For NaNs this still relies on something IEEE754 doesn't guarantee, > > as I cited, after a binary operation the sign bit of the NaN is > > unspecified, whether there is one NaN operand or two. > > It might be that all CPUs handle it the way you've implemented > > (that for one NaN operand the sign of NaN result will be the same > > as that NaN operand and for two it will be the sign of one of the two > > NaNs operands, never something else), but I think we'd need to check > > more than one implementation for that (I've only tried x86_64 and thus > > SSE behavior in it), so one would need to test i387 long double behavior > > too, ARM/AArch64, PowerPC, s390{,x}, RISCV, ... > > The guarantee given by IEEE754 is only for those copy, negate, abs, copySign > > operations, so copying values around, NEG_EXPR, ABS_EXPR, __builtin_fabs*, > > __builtin_copysign*. > > FWIW, RISC-V canonicalizes NaNs by clearing the sign bit; the signs of > the input NaNs do not factor in.
Just for binary operations and some unary, or also the ones that IEEE754 spells out (moves, negations, absolute value and copysign)? Jakub