This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc optimization constant propagation
- From: John Fine <johnsfine at verizon dot net>
- To: charfiasma at yahoo dot fr
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 04 Mar 2009 09:45:36 -0500
- Subject: Re: gcc optimization constant propagation
- References: <242704.78234.qm@web28502.mail.ukl.yahoo.com>
charfi asma wrote:
Why in the fist code, c is not considered as a constant (in spite that affich() does not change c)
I have no idea how deep into affich the compiler can look (for changes
to c). I expect/hope it looks as deep as it inlines.
But those operator<<() calls in affich go much deeper than you might be
thinking through. I expect the compiler should not and does not inline
that deep, nor check for changes to c that deep.
Maybe you want c to be a local variable, so as long as there isn't a
accessible copy of its address lying around, the compiler can assume it
isn't modified by code inside called functions.