This is the mail archive of the
mailing list for the GCC project.
Re: Draft "Unsafe fp optimizations" project description.
- To: dewar at gnat dot com
- Subject: Re: Draft "Unsafe fp optimizations" project description.
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Sun, 05 Aug 2001 16:01:30 +0200
- CC: gcc at gcc dot gnu dot org, ross dot s at ihug dot co dot nz
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <20010805123250.86999F2B7A@nile.gnat.com>
> <<I think what Toon meant was something like: if you throw all the
> possible distinct values for a given FP representation into a sack, and
> pick the operands at random from the sack, there's roughly a 50/50
> chance that B*C will overflow or underflow.
> I agree that's what he meant, but that is entirely wrong, the proportion
> of numbers that overflow is far far smaller. Remember we are talking about
> floating-point values here, not real values. There are as many fpt
> numbers with an exponent of 1 as there are with an exponent of 100 :-)
Robert, I think you'll have to do that analysis somewhat slower, because
I can't follow it. I agree my original analysis of A/B/C -> A/(B*C) was
wrong, because I didn't consider the value of A.
However, if we just look at B*C then this product will overflow or
underflow when the the sum of the exponents of B and C is higher than +N
or lower than -N. If we take B and C randomly from the FP-values-sack,
that will be true for half of the exponent values. Because there are
the same number of fp values for every exponent value, it follows that
the conclusion extends to "half of the fp values".
Toon Moene - mailto:email@example.com - 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)