comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GNAT Optimization of Constant Expressions
Date: Fri, 18 May 2007 21:44:17 -0500
Date: 2007-05-18T21:44:17-05:00	[thread overview]
Message-ID: <f2lo6a$jj6$1@jacob-sparre.dk> (raw)
In-Reply-To: 1179528686.946797.189500@w5g2000hsg.googlegroups.com

"Adam Beneschan" <adam@irvine.com> wrote in message
news:1179528686.946797.189500@w5g2000hsg.googlegroups.com...
> On May 18, 10:40 am, "Randy Brukardt" <r...@rrsoftware.com> wrote:
....
> So I suspect Randy is right, but I'm not sure.  If the hardware keeps
> just one extra mantissa bit internally when it does the subtraction,
> and uses the extra bit when it shifts left to normalize the result,
> then I think the two expressions will always produce the same result.

No, I think you have it right. The point is that if you subtract 1.0, you
depend on the hardware to do the right thing to preserve the last bit (which
is shifted out, then back in), whereas if you subtract 0.5 twice, you always
get the most accurate possible answer without worrying about what the
hardware does. Thus hardcore numerical programs do things like this so that
they don't depend on the characteristics of the hardware. Assuming an
optimizer doesn't screw that up...

Of course, if the hardware takes pains to preserve that extra bit (and a lot
of it does), none of this matters that much. Since most optimizers are at
least partially machine independent, however, they need to be careful; and
in any case, they need to avoid any optmizations which have the potential of
losing more bits.

                               Randy.






  reply	other threads:[~2007-05-19  2:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-16 22:37 GNAT Optimization of Constant Expressions David Smith
2007-05-17  4:50 ` Randy Brukardt
2007-05-17 20:03   ` Gautier
2007-05-17 20:46     ` Randy Brukardt
2007-05-17 22:49       ` David Smith
2007-05-17 23:38         ` Randy Brukardt
2007-05-18  7:58           ` Dmitry A. Kazakov
2007-05-18 11:27           ` Georg Bauhaus
2007-05-18 17:28             ` Randy Brukardt
2007-05-18 16:25       ` Ray Blaak
2007-05-18 17:40         ` Randy Brukardt
2007-05-18 22:51           ` Adam Beneschan
2007-05-19  2:44             ` Randy Brukardt [this message]
2007-05-18  9:05   ` Markus E Leypold
2007-05-18  9:47   ` Florian Weimer
2007-05-18 11:32     ` Duncan Sands
2007-05-18 17:20     ` Randy Brukardt
2007-05-18 17:35       ` Duncan Sands
     [not found]       ` <200705181935.23877.baldrick@free.fr>
2007-05-18 17:49         ` Duncan Sands
2007-05-17  5:30 ` Martin Krischik
2007-05-18  9:56 ` Duncan Sands
2007-05-18 15:39   ` David Smith
2007-05-18 17:08     ` Duncan Sands
     [not found]     ` <200705181908.54920.baldrick@free.fr>
2007-05-18 17:32       ` Duncan Sands
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox