https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Paul Eggert from comment #5)
> > The match pattern which causes the issue:
> > (simplify
> >  /* signbit(x) -> 0 if x is nonnegative.  */
> >  (SIGNBIT tree_expr_nonnegative_p@0)
> >  { integer_zero_node; })
> I don't see anything wrong with that match pattern.
> 
> I speculate that what's wrong is that GCC incorrectly thinks that 0.0/0.0 is
> nonnegative. Although it's tempting to say that the sign bit of a division
> is the exclusive OR of the sign bits of its operands, evidently this is not
> true on x86-64 when NaNs are involved.

tree_expr_nonnegative_p for divide does:
    case RDIV_EXPR:
    case TRUNC_DIV_EXPR:
    case CEIL_DIV_EXPR:
    case FLOOR_DIV_EXPR:
    case ROUND_DIV_EXPR:
      return RECURSE (op0) && RECURSE (op1);

Since 0.0 and 0.0 both don't have their sign bits set, GCC assumes diving them
won't produce a value with the sign bit set ...

I really think x86_64 div instruction is broken for IEEE really.

Reply via email to