dead code elimination in cp front end

Andrew Haley aph@redhat.com
Thu Mar 31 10:16:00 GMT 2011


On 31/03/11 09:49, charfi asma wrote:
> I compiled this code with g++  -Os -fipa-cp -S
> I expected that in test.s "assign of a" will be removed since value of  "y" did 
> not change  and so "a" will not be used. Am I wrong ??

In general, this wouldn't be a good optimization.  "a" is globally
visible, so any code that runs when main() exits might inspect it.
There isn't any such code in this case, but, generally speaking,
assignments to global static memory have to be preserved.

Andrew.



More information about the Gcc-help mailing list