Jim Wilson <[EMAIL PROTECTED]> writes:

> Andrew Pinski wrote:
> > I have been trying to figure out when the pattern vec_extract is
> > invoked.
> 
> I looked at this when I worked on the mips simd support.  In
> config/mips/mips-ps-3d.md I wrote
> ;; ??? This is only generated if we perform a vector operation that
> has to be
> ;; emulated.  There is no other way to get a vector mode bitfield extract
> ;; currently.
> 
> So it can be generated, but you have to use a vector mode that doesn't
> exist on the target.  Which kind of defeats the purpose of having
> it. Anyways, I think all we need here is a little syntax to get the
> operation we want.  Maybe a builtin function or something.

Personally, I think we should support operator[] for vectors.

That said, I'm not happy with a builtin function.  I think that we
should make every effort to make
    union { TYPE a[COUNT]; VECTOR v; } u;
    u.v = v;
    x = u.a[0];
use vec_extract, because in the absence of operator[] that is the
natural way for people to extract an element from a vector.

The other natural way is
    ((TYPE *)&v)[0]
which is technically an aliasing violation but one which gcc
explicitly accepts (search for VECTOR_TYPE in get_alias_set).
Although, since it is not documented, people should probably be
discouraged from doing this.

Ian

Reply via email to