https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82319
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Testing the following to match comments.
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 253134)
+++ gcc/match.pd (working copy)
@@ -2930,7 +2930,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
only one mantissa bit. */
bool signed_p = isign == SIGNED;
bool itype_fits_ftype_p
- = TYPE_PRECISION (itype) - signed_p <= significand_size (fmt);
+ = (TYPE_PRECISION (itype) - signed_p) <= significand_size (fmt);
}
/* TODO: allow non-fitting itype and SNaNs when
-fno-trapping-math. */
@@ -2964,20 +2964,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
{ constant_boolean_node (cmp == LT_EXPR || cmp == LE_EXPR || cmp ==
NE_EXPR,
type); })
/* Remove cast if CST is an integer representable by ITYPE. */
- (if (cst_int_p)
- (cmp @0 { gcc_assert (!overflow_p);
- wide_int_to_tree (itype, icst_val); })
- )
+ (if (cst_int_p && ! overflow_p)
+ (cmp @0 { wide_int_to_tree (itype, icst_val); }))
/* When CST is fractional, optimize
(FTYPE) N == CST -> 0
(FTYPE) N != CST -> 1. */
- (if (cmp == EQ_EXPR || cmp == NE_EXPR)
+ (if (! cst_int_p && (cmp == EQ_EXPR || cmp == NE_EXPR))
{ constant_boolean_node (cmp == NE_EXPR, type); })
- /* Otherwise replace with sensible integer constant. */
- (with
- {
- gcc_checking_assert (!overflow_p);
- }
+ /* Otherwise replace with sensible integer constant if it fits. */
+ (if (! overflow_p)
(icmp @0 { wide_int_to_tree (itype, icst_val); })))))))))
/* Fold A /[ex] B CMP C to A CMP B * C. */