On Fri, Feb 28, 2020 at 04:04:10PM +0100, Jakub Jelinek wrote:
> On Fri, Feb 28, 2020 at 08:53:11AM -0600, Segher Boessenkool wrote:
> > On Thu, Feb 27, 2020 at 09:25:27PM -0800, Steve Kargl wrote:
> > > On Fri, Feb 28, 2020 at 01:02:28PM +0800, Jiufu Guo wrote:
> > > > 
> > > > With -ffast-math -O3, this case `STOP 3` on a few platforms, e.g. 
> > > > ppc64le/x86.
> > > 
> > > IMHO, using -ffast-math with Fortran code is never correct.
> > > With this option, you got exactly what you wanted.
> > 
> > It happens with -O2 already.
> > 
> > The frontend generates a MIN_EXPR (or MAX_EXPR) for this, which is
> > undefined for NaNs already.  I think the testcase is just invalid?
> 
> Or maybe just the FE shouldn't use MIN_EXPR/MAX_EXPR if NaN is allowed,
> but fmax/fmaxf/fmaxl etc. or x < y ? x : y or whatever exactly is expected
> instead to yield the right answer for NaN?
> 

If a Fortran program does not use the IEEE_ARITHMETIC
module and specifically handle +-inf and nan and that
program generates one of those values, then that program
is in "undefined behavior" territory. 

Replacing MIN_EXPR/MAX_EXPR (everywhere?) would seem to
be a pessimization for correctly written code.


-- 
Steve

Reply via email to