This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: constant propagation optimization
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: charfi asma <charfiasma at yahoo dot fr>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 5 Mar 2009 08:33:28 -0800
- Subject: Re: constant propagation optimization
- References: <19576.49119.qm@web28513.mail.ukl.yahoo.com>
On Thu, Mar 05, 2009 at 11:39:45AM +0000, charfi asma wrote:
> intc;
> int main()
>
> {
>
> Calcul ca;
>
> c=3;
>
> ca.affich();
>
> ca.inc(c);
>
> cout << "the value of c is" << c << endl;
>
> return 0;
>
> }
[...]
> int main()
>
> {
>
> Calcul ca;
>
> ca.affich();
>
> c=3;
>
> ca.inc(c);
>
> cout << "the value of c is" << c << endl;
>
> return 0;
>
> }
>
> Why in the fist code, c is not considered as a constant (in spite that
> affich() does not change c)
Because GCC does not currently do the necessary analysis to know that
affich() does not change c; it therefore makes the conservative
assumption that it does.
-Nathan