comp.lang.ada
 help / color / mirror / Atom feed
* Non-static constant propagation in optimizing Ada compilers
@ 1990-01-05  1:37 Joe Orost
  1990-01-05 21:44 ` Non-static constant propagation in stt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joe Orost @ 1990-01-05  1:37 UTC (permalink / raw)


Ada compilers must be able to compute arithmetic expressions exactly.  It
says so in the language definition.  Should an optimizing compiler use this
"infinite precision" arithmetic when it is performing non-static constant
propagation?  What do you think?   For example:

   function example return float is
      f : float := 1.000000000000000000000000001;
      i : integer;
   begin
      i := integer(f);
      return f - float(i);
   end example;

If an optimizing compiler used "infinite precision" arithmetic,
it could replace the program with:

   function example return float is
   begin
      return 0.000000000000000000000000001;
   end example;

The other alternative is for the compiler to use the arithmetic of the
target machine to perform the calculations (possibly requiring emulation
if host /= target).  In this case, the function would return 0.0, which is
the answer you would get from a non-optimizing compiler.

Other similar problems occur when an optimizing compiler register allocates
floating point values, especially on a 68881/68882 where the registers hold
much more precision than single precision memory locations, which again will
cause different results than in a non-optimizing compiler.  I hear that they
are fixing this problem in the 68040.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-static constant propagation in
  1990-01-05  1:37 Non-static constant propagation in optimizing Ada compilers Joe Orost
@ 1990-01-05 21:44 ` stt
  1990-01-08 21:54 ` stt
  1990-01-10 21:24 ` stt
  2 siblings, 0 replies; 6+ messages in thread
From: stt @ 1990-01-05 21:44 UTC (permalink / raw)



An Ada expression is always allowed to evaluate to a result more
accurate than that required by the type.
This can be due either to compile-time infinite
precision calculation, or by simply using greater
precision at run-time.
The only absolute requirement for accuracy has to do
with operations where both operands are model numbers.
See ARM 4.5.7.

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-static constant propagation in optimizing Ada compilers
@ 1990-01-07  4:20 Michael Hunter
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Hunter @ 1990-01-07  4:20 UTC (permalink / raw)



joe@petsd.UUCP (Joe Orost) writes:
>Ada compilers must be able to compute arithmetic expressions exactly.  It
>says so in the language definition.  Should an optimizing compiler use this
>"infinite precision" arithmetic when it is performing non-static constant
>propagation?  What do you think?   For example:
really!!!!  or just between model numbers within the range of the type?  Can
anybody give LRM section numbers?

                                                Michael

Mike Hunter - Box's and CPU's from HELL: iapx80[012]86, PR1ME 50 Series, 1750a
UUCP: {ames!elroy, <routing site>}!gryphon!pnet02!bagpiper
INET: bagpiper@pnet02.gryphon.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-static constant propagation in
  1990-01-05  1:37 Non-static constant propagation in optimizing Ada compilers Joe Orost
  1990-01-05 21:44 ` Non-static constant propagation in stt
@ 1990-01-08 21:54 ` stt
  1990-01-09 13:10   ` Robert Firth
  1990-01-10 21:24 ` stt
  2 siblings, 1 reply; 6+ messages in thread
From: stt @ 1990-01-08 21:54 UTC (permalink / raw)



With regard to accuracy of compile-time calculations...

In ARM 4.10:4, it states:
   . . . Furthermore, if a universal expression is a static expression,
then the evaluation must be exact.

Let's hope they don't try to define "SQRT" on universal reals ! ;-*

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-static constant propagation in
  1990-01-08 21:54 ` stt
@ 1990-01-09 13:10   ` Robert Firth
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Firth @ 1990-01-09 13:10 UTC (permalink / raw)


In article <20600032@inmet> stt@inmet.inmet.com writes:

>In ARM 4.10:4, it states:
>   . . . Furthermore, if a universal expression is a static expression,
>then the evaluation must be exact.
>
>Let's hope they don't try to define "SQRT" on universal reals ! ;-*

The sentence quoted was perpetrated by one of the Neoplatonists on
the language design team.  The point of the joke, of course, is that
in Ada all 'universal' expressions yield only rational results, and
so may indeed be computed exactly.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-static constant propagation in
  1990-01-05  1:37 Non-static constant propagation in optimizing Ada compilers Joe Orost
  1990-01-05 21:44 ` Non-static constant propagation in stt
  1990-01-08 21:54 ` stt
@ 1990-01-10 21:24 ` stt
  2 siblings, 0 replies; 6+ messages in thread
From: stt @ 1990-01-10 21:24 UTC (permalink / raw)



As Robert Firth said, the point of my joke about SQRT on universals
was exactly that the result is not always a rational number.
The definition of Ada does not currently include any operations on universal
reals which produce irrational results.  If we were to add SQRT,
then the cited wording would have to change.  I have no expectation
that SQRT will be added to the set of operations defined on
universal reals, by the way...

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

P.S. I wouldn't rule out some clever implementation which could
represent all algebraic numbers "exactly", but it would clearly
have to be more complicated than simply a pair of universal
integers as is used for rationals
(probably a tree structure of some sort, requiring symbolic
evaluation, etc).
-T

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1990-01-10 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-01-05  1:37 Non-static constant propagation in optimizing Ada compilers Joe Orost
1990-01-05 21:44 ` Non-static constant propagation in stt
1990-01-08 21:54 ` stt
1990-01-09 13:10   ` Robert Firth
1990-01-10 21:24 ` stt
  -- strict thread matches above, loose matches on Subject: below --
1990-01-07  4:20 Non-static constant propagation in optimizing Ada compilers Michael Hunter

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