Currently in GCC, you can access an element of a vector by using an union or by accessing the element via a pointer. Code like, (ignore the fact vector is not defined to  __attribute__((vector_size(16)))  ):

float f(vector float t)
  return *(float*)&t;

Would store the whole vector to memory and then load back into a floating point register. This is not a good thing as some targets (x86_64) actually has returns scalar values in the vector register. On other targets it can cause other issues. The correct way to solve this issue is by having GCC produce a BIT_FIELD_REF for the INDIRECT_REF. After doing that, this function for an example on the SPU target (which is not in the FSF GCC yet), we just get a branch for the return and no other code. On PPC (with altivec), we get a stevx instead of a full stvx which should save on cycles and it also saves on stack size in larger functions which does the above more.

Patch was posted at:

None: VecSetGeneration (last edited 2008-01-10 19:38:45 by localhost)