public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re:Re: help with MMX and inline asm (all ok)
@ 2004-04-09  9:09 Andrea Pretto
  2004-04-09 13:54 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Pretto @ 2004-04-09  9:09 UTC (permalink / raw)
  To: gcc-help

All ok

----------------------------------------------------
#include <stdio.h>

//file: mmx.c
// gcc -o mmx -Wall -mmmx mmx.c ( it run also without
-mmmx flag)

int main ( void ){
  int v[2] = { 5, 8};
  int t[2] = { 6, 17};
  int r[2] = { 0, 0};
  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]);
    asm (
       "movq %0 , %%mm1\n\t"
       "movq %1 , %%mm0\n\t"
       "paddd %%mm0, %%mm1\n\t"
       "movq %%mm1, %2\n\t"
       :"=m" (v[0]) // %0 first array
       :"m" (t[0]), // %1 second array
       "m" (r[0]) // %2 result
       );
   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;
}
-----------------------------------------------

______________________________________________________________________
Yahoo! Mail: 6MB di spazio gratuito, 30MB per i tuoi allegati, l'antivirus, il filtro Anti-spam
http://it.yahoo.com/mail_it/foot/?http://it.mail.yahoo.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: help with MMX and inline asm (all ok)
  2004-04-09  9:09 Re:Re: help with MMX and inline asm (all ok) Andrea Pretto
@ 2004-04-09 13:54 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2004-04-09 13:54 UTC (permalink / raw)
  To: Andrea Pretto; +Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-09 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-09  9:09 Re:Re: help with MMX and inline asm (all ok) Andrea Pretto
2004-04-09 13:54 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).