examples of using MMX/SSE/SSE2 intrinsics?

dean gaudet dean@arctic.org
Wed Feb 19 05:37:00 GMT 2003


i can't seem to find any examples of code using the vector intrinsics in
gcc 3.x.  i'm puzzled by a bunch of things.

in 3.2.3 (debian unstable) i can't seem to do things like:

	__m64 m;
	int i;

	i = (int)(long long)m;

that results in the error:
	can't convert between vector values of different size

the above does appear to work in a 3.3 snapshot i've tried.  the only
way i can seem to do it in 3.2 is to create a "union { __m64 x; int y };"

i'm unsure of the "correct" way to create vector constants... after some
experimentation, the following appears to do what i want:

	static const __v4hi two = {2, 2, 2, 2};

i'm not sure if there's a way to create "unnamed" constants like
that... which would simplify some expressions.

i seem to have to cast things all over the place... and i generally don't
like casting -- but maybe i'm doing something wrong.  (maybe the thing
i'm doing wrong is using the mmintrin.h header file rather than using
the intrinsics directly... this header file seems to really encourage
casting.)

the main reason i'm trying to use the intrinsics is because i'm lazy and
don't feel like doing register allocation in assembly... but the code
quality is a bit lacking :)  there seem to be a bunch of superfluous
register copies.  one random example:

    1312:       0f eb dd                por    %mm5,%mm3
    1315:       0f 6f eb                movq   %mm3,%mm5
    1318:       0f 6f 1b                movq   (%ebx),%mm3

could be:

	por %mm3,%mm5
	movq (%ebx),%mm3

this sort of thing is all over the place.

-dean

p.s. i'm not on the mailing list, be sure to cc me, thanks.



More information about the Gcc-help mailing list