maxval on -inf and nan in Fortran

Jakub Jelinek jakub@redhat.com
Fri Feb 28 15:04:00 GMT 2020


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?

	Jakub



More information about the Gcc-patches mailing list