Re: maxval on -inf and nan in Fortran

2020-03-01 Thread Jiufu Guo
Joseph Myers writes: > On Fri, 28 Feb 2020, Tobias Burnus wrote: > >> Regarding MIN and MAX: I think the IEEE 754 decided at some point >> decided that MAX(x, NaN) = x (IEEE 754:2008 alias ISO 60559:2011, if I >> recall correctly). I think one has to check what exactly the test case >> does and

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Joseph Myers
On Fri, 28 Feb 2020, Tobias Burnus wrote: > Regarding MIN and MAX: I think the IEEE 754 decided at some point > decided that MAX(x, NaN) = x (IEEE 754:2008 alias ISO 60559:2011, if I > recall correctly). I think one has to check what exactly the test case > does and what is guaranteed where. I

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Jakub Jelinek
On Fri, Feb 28, 2020 at 06:50:20PM +0100, Thomas Koenig wrote: > Am 28.02.20 um 17:58 schrieb Steve Kargl: > > Replacing MIN_EXPR/MAX_EXPR (everywhere?) would seem to > > be a pessimization for correctly written code. > > Also note the following part of changes.html for 9.2: > > The MAX and MIN

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Segher Boessenkool
On Fri, Feb 28, 2020 at 04:32:05PM +0100, Jakub Jelinek wrote: > On Fri, Feb 28, 2020 at 04:11:15PM +0100, Tobias Burnus wrote: > > On 2/28/20 3:53 PM, Segher Boessenkool wrote: > > > It happens with -O2 already. The frontend generates a MIN_EXPR (or > > > MAX_EXPR) for this, which is undefined

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Thomas Koenig
Am 28.02.20 um 17:58 schrieb Steve Kargl: Replacing MIN_EXPR/MAX_EXPR (everywhere?) would seem to be a pessimization for correctly written code. Also note the following part of changes.html for 9.2: The MAX and MIN intrinsics are no longer guaranteed to return any particular value in case one

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Steve Kargl
On Fri, Feb 28, 2020 at 04:11:15PM +0100, Tobias Burnus wrote: > On 2/28/20 3:53 PM, Segher Boessenkool wrote: > > 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? > > Ups,

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Steve Kargl
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

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Jakub Jelinek
On Fri, Feb 28, 2020 at 04:11:15PM +0100, Tobias Burnus wrote: > On 2/28/20 3:53 PM, Segher Boessenkool wrote: > > 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? > > Ups,

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Tobias Burnus
On 2/28/20 3:53 PM, Segher Boessenkool wrote: 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? Ups, that shouldn't happen. It does seem to work here (x86-64-gnu-linux), however,

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Jakub Jelinek
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. > >

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Segher Boessenkool
Hi Tobias, On Fri, Feb 28, 2020 at 10:58:36AM +0100, Tobias Burnus wrote: > (Do you really need to post to gcc@, fortran@ and gcc-patches@? > Shouldn't be one of the list sufficient – like fortran@?) Many people do not read that list. I asked Jiu Fu to post to both fortran@ and one of gcc@ and

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Segher Boessenkool
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

Re: maxval on -inf and nan in Fortran

2020-02-28 Thread Tobias Burnus
Hi, (Do you really need to post to gcc@, fortran@ and gcc-patches@? Shouldn't be one of the list sufficient – like fortran@?) On 2/28/20 6:02 AM, Jiufu Guo wrote: When I check a PR93709, I find the testcase maxlocval_4.f90 […] With -ffast-math -O3, this case `STOP 3` on a few platforms, e.g.

Re: maxval on -inf and nan in Fortran

2020-02-27 Thread Steve Kargl
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. -- Steve

maxval on -inf and nan in Fortran

2020-02-27 Thread Jiufu Guo
Hi, When I check a PR93709, I find the testcase maxlocval_4.f90 and minlocval_4.f90 are checking `maxval/minval` on `-inf` and `nan`. https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=blob_plain;f=gcc/testsuite/gfortran.dg/maxlocval_4.f90;hb=HEAD There are code like: ``` l5 = .true. l5(1,1) =

maxval on -inf and nan in Fortran

2020-02-27 Thread Jiufu Guo
Hi, When I check a PR93709, I find the testcase maxlocval_4.f90 and minlocval_4.f90 are checking `maxval/minval` on `-inf` and `nan`. https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=blob_plain;f=gcc/testsuite/gfortran.dg/maxlocval_4.f90;hb=HEAD There are code like: ``` l5 = .true. l5(1,1) =