help with MMX and inline asm (all ok)
Ian Lance Taylor
ian@wasabisystems.com
Fri Apr 9 13:54:00 GMT 2004
This works also, with no inline assembler. With -mmx it generates
paddd. Without -mmx it does the vector addition using ordinary x86
instructions.
Ian
#include <stdio.h>
#include <string.h>
//file: mmx.c
// gcc -o mmx -Wall -mmmx mmx.c ( it run also without -mmmx flag)
typedef int v2si __attribute__ ((vector_size (8)));
int main ( void ){
int v[2] = { 5, 8};
int t[2] = { 6, 17};
int r[2] = { 0, 0};
v2si rv;
printf("V: %i %i\n",v[0], v[1]);
printf("T: %i %i\n",t[0], t[1]);
printf("R: %i %i\n",r[0], r[1]);
rv = *(v2si *) &v[0] + *(v2si *) &t[0];
memcpy (&r, &rv, sizeof r);
printf("\n\nV: %i %i\n",v[0], v[1]);
printf("T: %i %i\n",t[0], t[1]);
printf("R: %i %i\n",r[0], r[1]);
return 0;
}
More information about the Gcc-help
mailing list