Re: g++ optimization question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux