On Tue, Nov 8, 2022 at 12:20 PM Jakub Jelinek 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*. Ughh, that's unfortunate. OK, I've added a big note. > > Otherwise LGTM (but would be nice to get into GCC13 not just > +, but also -, *, /, sqrt at least). Minus is trivial as we can implement it with a negate and plus. I have a patch queued up for that. The rest require a bit more thought, though perhaps with what we have so far can serve as a base. I'll look into it. Attached is the patch I'm retesting. Thanks for your patience, and copious help here. Aldy