On Thu, Nov 26, 2020 at 01:56:03PM -0000, Roger Sayle wrote: > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -3998,7 +3998,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (cmp @0 { build_real (TREE_TYPE (@1), dconst0); })) > /* x != NaN is always true, other ops are always false. */ > (if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1)) > - && ! HONOR_SNANS (@1)) > + && ! flag_trapping_math)
Shouldn't this one stay as is for cmp == EQ_EXPR || cmp == NE_EXPR? I mean, == or != only raise exceptions on sNaNs, while other simple comparisons raise on both sNaNs and qNaNs. > --- a/gcc/simplify-rtx.c > +++ b/gcc/simplify-rtx.c > @@ -5732,12 +5732,13 @@ simplify_const_relational_operation (enum rtx_code > code, > if (REAL_VALUE_ISNAN (*d0) || REAL_VALUE_ISNAN (*d1)) > switch (code) > { > + case NE: > + return flag_trapping_math ? 0 : const_true_rtx; And here too (for NE and would need moving EQ later too. > case UNEQ: > case UNLT: > case UNGT: > case UNLE: > case UNGE: > - case NE: > case UNORDERED: > return const_true_rtx; > case EQ: > @@ -5746,6 +5747,7 @@ simplify_const_relational_operation (enum rtx_code code, > case LE: > case GE: > case LTGT: > + return flag_trapping_math ? 0 : const0_rtx; > case ORDERED: > return const0_rtx; > default: Jakub