This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize abs(x) < 0.0
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 21 Jul 2002 20:09:00 +0200
- Subject: Re: [PATCH] Optimize abs(x) < 0.0
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <Pine.LNX.4.33.0207211015120.27238-100000@www.eyesopen.com>
Roger Sayle wrote:
> > Now computer hardware is forced to project that three valued logic onto a
> > two valued logical "true, false" dichotomy. The solution chosen is to have
> > both comparisons above return "false". That means that to check for a NaN
> > and use a > or <= comparison, you have to use *both*, else the NaN will
> > just escape your check.
>
> When applying a code transformation it is sufficient to guarantee that
> the behaviour of the transformed code is the same as the original.
> In this case, I don't have to explicitly "check for a NaN" with two
> comparisons iff the optimized code produces the same results in the
> presence of NaNs and finite values.
Yep, rethinking this, it is the original code writer who should make sure
that abs(a) < 0.0 is the correct check, i.e.:
> [You might also appreciate that "x == x" is a better explicit check
> for finite vs. NaN that would require only a single comparison]
He/she should have done the above check.
The code in the patch is OK because it doesn't introduce a hole where there
wasn't one before :-)
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)