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: Why so bad optimized code ?


Mike Stump wrote:
> > From: Joern Rennecke <amylaar@cambridge.redhat.com>
> > To: denisc@overta.ru (Denis Chertykov)
> > Date: Wed, 21 Mar 2001 00:30:35 +0000 (GMT)
> > Cc: gcc@gcc.gnu.org
> 
> > > int main(void)
> > > {
> > >   time->day = 5;
> > >   time->hour= 9;
> > >   time->min = 10;
> > >   time->sec =10;
> > > }
> 
> > We have two mechanisms that could be used to do that:
> > - (only if -fstrict-aliasing is enabled): Although the individual components
> >   are characters, the dereference is of a structure pointer, not of a
> >   character pointer, so I suppose the memory accesses should get non-null
> >   alias sets.
> 
> Nope, don't think so?!  char can alias anything, including the
> structure pointer.

Although a general "char *" can alias anything (as a special case),
dereferencing a struct field does not have the same property.  E.g. in
this case the char struct fields _can_ alias other targets of "char *"
pointers, for the same reason that int struct fields can alias other
targets of "int *" pointers and in some cases int fields of other struct
types.  However the char struct fields cannot alias e.g. other int
types.

So the generated code could be better.

-- Jamie


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