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, 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.


-- 
zw    A man who has never gone to school may steal from a freight car, but
      if he has a university education, he may steal the whole railroad.
      	-- Theodore Roosevelt


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