Accessing the vector elements

Ian Lance Taylor iant@google.com
Tue Oct 24 06:42:00 GMT 2006


Chris Lattner <clattner@apple.com> writes:

> > But at my previous
> > company, we got significantly better generated code in some cases by
> > breaking that aliasing.  In particular this aliasing forces a pointer
> > to a vector of char to alias char* and therefore alias everything.
> > But if the compiler breaks that aliasing, then your suggestion of
> > using a cast will fail in some cases.
> 
> The compiler shouldn't break that aliasing, and using a union will
> give you poor code anyway.  LLVM will optimize either idiom into
> element extract/insert operations, but I don't think GCC will in an
> any case.  If you care about performance with GCC, you have to use
> ISA-specific builtins.

gcc generates efficient insert/extract with the union if the backend
is written correctly.  See the uses of vec_extract and vec_get in
extract_bit_field and store_bit_field in expmed.c.

Ian



More information about the Gcc-help mailing list