Fwd: GCC Optimization for expressions
Ian Lance Taylor
iant@google.com
Tue Dec 2 15:30:00 GMT 2008
Vincent Lefevre <vincent+gcc@vinc17.org> writes:
> On 2008-12-01 13:02:21 -0800, Ian Lance Taylor wrote:
>> "Nirav Shah" <nirav4ever4u@gmail.com> writes:
>>
>> > No expression is evaluated in loop nor any particular intermediate
>> > result is used more than once. Given this, can I get benefit in terms
>> > of lesser clock cycle to execute the computation if done in a single
>> > statement as compared to done over multiple statements with local
>> > variables?
>>
>> No. When optimizing, the compiler converts your program into an
>> internal representation in SSA form. The number of local variables
>> used in the original program is irrelevant to the generated code.
>
> This may be what GCC currently does, but this is a bug when extended
> precision is used to evaluate an expression.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
Yes. By default, using additional local variables does not affect
that bug in any meaningful way. However, you are correct in that if
you use the -ffloat-store option gcc will essentially treat all local
variables with floating point type as though they were declared with
the volatile qualifier. That is indeed a case where it matters
whether or not you use local variables.
By the way, that long-standing bug will likely be fixed in gcc 4.5
(i.e., not the next release, which will be 4.4, but the one after
that).
Ian
More information about the Gcc-help
mailing list