comp.lang.ada
 help / color / mirror / Atom feed
From: David Smith <david.smith@gmail.com>
Subject: Re: GNAT Optimization of Constant Expressions
Date: 17 May 2007 15:49:13 -0700
Date: 2007-05-17T15:49:13-07:00	[thread overview]
Message-ID: <1179442153.169828.109970@l77g2000hsb.googlegroups.com> (raw)
In-Reply-To: <f2ier6$c09$1@jacob-sparre.dk>


> > I agree for any function call, but in the special case of functions from
> > Generic_Elementary_Functions, it is _not_ asking a lot! A decent compiler
> > should perform optimizations around these functions as well as around
> > arithmetic operators.

The purpose in leaving them in was to test this aspect of the
optimization process.  This is a very common expression to see in
legacy scientific codes written by novices, and I wanted to know if
GNAT can handle naive structures as well as Fortran compilers do.  If
it can't, then many scientists and potential Ada converts will be
turned off because they'll write a naive bit of code for a benchmark
and find that Ada is much slower than Fortran without trying to
understand why.

I understand that the FP ops are not associative, but doesn't the gcc -
O3 imply that the user chooses speed over accuracy?  And especially if
the user passes -ffast-math the compiler should get the hint.

> There are optimizations that you can do safely, like common subexpression
> evaluation, but there are many fewer of them than you have with integer
> optimizations. Luckily, most of the code in a program (any program, once you
> take address calculations like array indexing into account) is integer code.
> It is very important to do a good job on integer expressions, much less
> valuable of float ones (because of the limited things that you can do).

This may be true, but FP ops are very expensive, so trimming those can
potentially save more than you might think.    In this example, the
common expression elimination speeds the code up by a factor of 10,
roughly.

-Dave




  reply	other threads:[~2007-05-17 22:49 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 [this message]
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
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