comp.lang.ada
 help / color / mirror / Atom feed
From: joe@petsd.UUCP (Joe Orost)
Subject: Non-static constant propagation in optimizing Ada compilers
Date: 5 Jan 90 01:37:04 GMT	[thread overview]
Message-ID: <1735@petsd.UUCP> (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.

             reply	other threads:[~1990-01-05  1:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-01-05  1:37 Joe Orost [this message]
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
replies disabled

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