On Tue, Sep 6, 2022 at 9:35 AM Jakub Jelinek <[email protected]> wrote:
>
> On Tue, Sep 06, 2022 at 09:29:01AM +0200, Aldy Hernandez wrote:
> > The gfortran.dg/minlocval*.f90 tests are generating conditionals past
> > the infinities. For example:
> >
> > if (x <= +Inf)
> > foo (x);
> > else
> > bar (x);
> >
> > It seems to me that the only possible value for x on the false side is
> > either NAN or undefined (for !HONOR_NANS).
>
> No, none of the ==, <, <=, >, >= comparisons are ever true if one
> or both operands are NaN (only != will be true in those cases from the
> standard comparisons, when not counting UNORDERED_EXPR and the likes).
> So, x < -Inf or x > +Inf are always false, we just can't optimize those
> away without -ffast-math because they could raise an exception on sNaN.
> But I think not optimizing such operations away if we care about exceptions
> is the duty of DCE etc.
No, no. I'm not talking about optimizing them away. I'm talking about
representing what is going on in the IL.
For example, for:
if (x > 5.0)
foo (x); // {5.0, +Inf] !NAN
else
bar (x); // [-Inf, 5.0] ?NAN
So on the true side we know x is in the {5.0, +Inf] range, plus we
know it can't be a NAN. On the false side we know x is either [-Inf,
5.0] or a NAN.
What I'm trying to do is represent the possible ranges for the false side of:
if (x <= Inf)
...
Aldy