Optimizing calls to GSL functions
Tommy Nordgren
tommy.nordgren@comhem.se
Sun Jun 10 16:32:00 GMT 2007
On 9 jun 2007, at 10.19, Brian Gough wrote:
> At Sat, 9 Jun 2007 04:25:55 +0200,
> Tommy Nordgren wrote:
>> Are there any way, when using the GNU Compiler Collection, to make
>> the compiler optimize expressions where the same function call
>> occurs more than once. (Same function, same parameters) GCC does
>> this for standard C functions such as cos and sin, when passed -O3
>> or -Os -fgcse I'm interested in this, because most special functions
>> computed by GSL are probably more expensive to compute than the
>> basic transcendental functions, and in general you can get many
>> common subexpressions when generating C code from symbol math
>> programs.
>
> __attribute__ ((pure), see "Function attributes" in the GCC manual for
> details.
>
> --
> Brian Gough
Thanks, Brian. I got another suggestion too, : __attribute__((const)) .
I've checked that it works in C++ headers too.
I suggest you mention the use of __attribute__ in the next edition of
"An Introduction to GCC"
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
tommy.nordgren@comhem.se
More information about the Gsl-discuss
mailing list