Tweak the constant folding of X CMP X in when X can't be a NaN.
2022-03-16 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* match.pd (X CMP X -> true): Test tree_expr_maybe_nan_p
instead of HONOR_NANS.
(X LTGT X -> false): Enable if X is not tree_expr_maybe_nan_p, as
this can't trap/signal.
(simplify
(cmp @0 @0)
(if (! FLOAT_TYPE_P (TREE_TYPE (@0))
- || ! HONOR_NANS (@0))
+ || ! tree_expr_maybe_nan_p (@0))
{ constant_boolean_node (true, type); }
(if (cmp != EQ_EXPR
/* With -ftrapping-math conversion to EQ loses an exception. */
(cmp @0 @0)
(if (cmp != NE_EXPR
|| ! FLOAT_TYPE_P (TREE_TYPE (@0))
- || ! HONOR_NANS (@0))
+ || ! tree_expr_maybe_nan_p (@0))
{ constant_boolean_node (false, type); })))
(for cmp (unle unge uneq)
(simplify
(unordered @0 @0)))
(simplify
(ltgt @0 @0)
- (if (!flag_trapping_math)
+ (if (!flag_trapping_math || !tree_expr_maybe_nan_p (@0))
{ constant_boolean_node (false, type); }))
/* x == ~x -> false */