Re: help with MMX and inline asm (all ok)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux