Extracting members of a SIMD type?

Segher Boessenkool segher@kernel.crashing.org
Tue Dec 9 13:27:00 GMT 2003


> I've been playing around with the builtin SIMD support in 3.4, but have
> come to one very confusing problem. Given a vector type (V4SI in my 
> case),
> how do you extract parts of it? I tried indexing and shift/mask, 
> neither of
> which are accepted, and the info pages have no examples of how to do 
> this.
> I would sort of presume that you can access them without using a
> target-specific builtin, considering everything else gets synthesized 
> on a
> machine without hardware SIMD...

Create a union of your vector type and an array of the type of the 
parts.
Like:

union v4si_conv {
	v4si v;
	int e[4];
};


Store the vector to v, read the elements from e[].


Cheers,

Segher



More information about the Gcc-help mailing list