On Mon, 31 Jan 2022, Richard Biener via Gcc-patches wrote:

> I wonder if it would make sense to handle it similar to
> 
>       inexact = real_arithmetic (&value, code, &d1, &d2);
>       real_convert (&result, mode, &value);
> 
>       /* Don't constant fold this floating point operation if
>          the result has overflowed and flag_trapping_math.  */
>       if (flag_trapping_math
>           && MODE_HAS_INFINITIES (mode)
>           && REAL_VALUE_ISINF (result)
>           && !REAL_VALUE_ISINF (d1)
>           && !REAL_VALUE_ISINF (d2))
>         return NULL_TREE;
> 
> thus whenever we fold to NaN but flag_trapping_math is set,
> do not fold?  We already exclude NaN operands earlier

Yes, it's true in general that a NaN result for non-NaN operands means 
"invalid" is raised.  While an infinite result for finite operands means 
either "overflow" (if inexact) or "divide by zero" (if exact).  
(Underflow is more complicated.)

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to