g++ optimization question
Richard Li
richardpku@gmail.com
Sat Sep 29 09:40:00 GMT 2007
I tested this code with "g++ -S -O1", and checked the generated
assembly code. I found G++ dropped the statement "e = d * 1"
completely, since "e" is a local variable and is assigned a value, but
never used later.
If "e" is used later, G++ would optimize "e = d * 1 " as "e = d".
On 9/29/07, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> Can anybody let me know whether g++ will optimize for the following case?
>
> void f(double d)
> double e;
> ..... do something
>
> e = d * 1.;// will this be optimized as e = d;
> }
>
> Thanks,
> Peng
>
More information about the Gcc-help
mailing list