https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118483
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot
gnu.org
Status|NEW |ASSIGNED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> Adding
>
> (for eqne (eq ne)
> (for cmp (lt le eq ne ge gt)
> icmp (ge gt ne eq lt le)
> (simplify
> (eqne (cmp @0 @1) (icmp @0 @1))
> (if (!FLOAT_TYPE_P (TREE_TYPE (@0)))
> { constant_boolean_node (eqne == NE_EXPR, type); }))))
>
> fixes that (make more robust with tcc_comparison, inverted_...,
> inverted_...with_nans and handle NaNs like elsehwere).
Then simplier fix is replace:
```
/* x == ~x -> false */
/* x != ~x -> true */
(for cmp (eq ne)
(simplify
(cmp:c @0 (bit_not @0))
{ constant_boolean_node (cmp == NE_EXPR, type); }))
```
With
```
(for eqne (eq ne)
(simplify
(eqne:c @0 (maybe_bit_not @1))
(with { bool was_cmp; }
(if (bitwise_inverted_equal_p (@0, @1, wascmp))
{ constant_boolean_node (eqne == NE_EXPR, type); }))))
```