[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-patches
Subject: Re: [PATCH] fold-const: do not fold 'inf/inf' with -ftrapping-math [PR95115]
From: Joseph Myers <joseph () codesourcery ! com>
Date: 2022-01-31 23:32:44
Message-ID: alpine.DEB.2.22.394.2201312330240.853510 () digraph ! polyomino ! org ! uk
[Download RAW message or body]
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
joseph@codesourcery.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic