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 02:56:50PM +0200, Richard Guenther wrote:
> > > > >     void nconc (unsigned x, unsigned y) {
> > > > >         unsigned *ptr = &x;
> > > > >         while(!(*ptr & 3))
> > > > >             ptr = &((cons *)(*ptr))->cdr;
> > > > >         *ptr = y;
> > > > >     }
> 
> 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;
>      }
> 
> which makes aliasing see that the store is not dead and in fact it never will
> be to the argument area.

Thank you. But while this does indeed save the store, I haven't made
sure nconc is never called with arguments where the while condition is
never true, and nothing should happen. (This version is a little
simplified, just to show the problem.) Another workaround seems to be to
declare ptr as volatile unsigned *. Or, just compile with
-fno-strict-aliasing.


[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