Re: More fun with aliasing - removing assignments?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 02, 2005 at 09:08:51AM -0400, Diego Novillo wrote:
> On Tue, Aug 02, 2005 at 02:56:50PM +0200, Richard Guenther wrote:
> > Oh, and a workaround and slight correction would be to write
> > 
> >     void nconc (unsigned x, unsigned y) {
> >          unsigned *ptr = &((cons *)x)->cdr;
> >          while(!(*ptr & 3))
> >              ptr = &((cons *)(*ptr))->cdr;
> >          *ptr = y;
> >      }
> > 
> No.  Same problem.  The aliaser would say "yes, ptr points
> anywhere, but it cannot escape the local frame".  The final store
> is dead just the same.
> 
> We only "get it right" because we do not distinguish between
> different degrees of points-anywhere.

Then the alias analyzer's broken.  This isn't pointer arithmetic in the
sense that you mean.  It would be if the line were:

             ptr = &((cons *)(ptr))->cdr;

which is equivalent to some offset plus ptr.  But there's an extra
dereference:

             ptr = &((cons *)(*ptr))->cdr;
                              ^

As far as I can tell, this code doesn't actually violate any of the
aliasing rules.  It just looks funny.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux