This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: random thought - optimizer


On Sun, 01 Jul 2001, Zack Weinberg wrote:

> On Sun, Jul 01, 2001 at 11:25:34PM -0400, Diego Novillo wrote:
> > > 
> > > Now, it seems to me that the as-if rule says we could generate instead
> > > 
> > > init:
> > > 	ret
> > > 
> > That would be the wrong code to generate.  Variable 'initialized'
> > is only set to 0 the first time init() is executed.  Subsequent
> > calls to init() should see variable 'initialized' set to 1.
> 
> You've missed that 'initialized' is local to init() and its address is
> never taken.  Therefore, the existence and value of 'initialized' are
> invisible to the rest of the program.  Further, init() does nothing in
> either case except set 'initialized'.  I believe this means it can be
> eliminated.
> 
I thought you said there was more code in the if() statement,
sorry.  In principle it's not possible to constant propagate
'initialized'  because it's static.

But DCE should note that all the statements in the if body are
local assignments, this should allow it to remove the body.


Diego.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]