[5320] Add a simple SSSE3 test.
Revision: 5320
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5320 Author: balrog Date: 2008-09-25 18:41:28 +0000 (Thu, 25 Sep 2008)
Log Message:
-----------
Add a simple SSSE3 test.
Added Paths:
-----------
trunk/tests/test-i386-ssse3.c
Added: trunk/tests/test-i386-ssse3.c
===================================================================
tests/test-i386-ssse3.c +42 -0
@@ -0,0 +1,42 @@ +/* See if various MMX/SSE SSSE3 instructions give expected results */ +#include <stdio.h> +#include <string.h> + +int main (int argc,char *argv[]) { +char hello[16 ]; +const char ehlo[8 ] ="EHLO " ; +uint64_t mask =0x8080800302020001 ; + +uint64_t a =0x0000000000090007 ; +uint64_t b =0x0000000000000000 ; + +const char c[16 ] ="LLOaaaaaaaaaaaaa" ; +const char d[16 ] ="aaaaaaaaaaaaaaHE" ; + +/* pshufb mm1/xmm1, mm2/xmm2 */ + asmvolatile ("movq (%0), %%mm0" : :"r" (ehlo) :"mm0" ,"mm1" ); + asmvolatile ("movq %0, %%mm1" : :"m" (mask)); + asmvolatile ("pshufb %mm1, %mm0" ); + asmvolatile ("movq %%mm0, %0" :"=m" (hello)); +printf ("%s\n" , hello); + +/* pshufb mm1/xmm1, m64/m128 */ + asmvolatile ("movq (%0), %%mm0" : :"r" (ehlo) :"mm0" ); + asmvolatile ("pshufb %0, %%mm0" : :"m" (mask)); + asmvolatile ("movq %%mm0, %0" :"=m" (hello)); +printf ("%s\n" , hello); + +/* psubsw mm1/xmm1, m64/m128 */ + asmvolatile ("movq %0, %%mm0" : :"r" (a) :"mm0" ); + asmvolatile ("phsubsw %0, %%mm0" : :"m" (b)); + asmvolatile ("movq %%mm0, %0" :"=m" (a)); +printf ("%i - %i = %i\n" ,9 ,7 , -(int16_t ) a); + +/* palignr mm1/xmm1, m64/m128, imm8 */ + asmvolatile ("movdqa (%0), %%xmm0" : :"r" (c) :"xmm0" ); + asmvolatile ("palignr $14, (%0), %%xmm0" : :"r" (d)); + asmvolatile ("movdqa %%xmm0, (%0)" : :"r" (hello)); +printf ("%5.5s\n" , hello); + +return 0 ; +}