cirrus: Unbreak ISA support
[qemu.git] / tests / test-i386-ssse3.c
blob0a42bd03e29a0acb48df7d296322685f45a9bc42
1 /* See if various MMX/SSE SSSE3 instructions give expected results */
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdint.h>
6 int main(int argc, char *argv[]) {
7 char hello[16];
8 const char ehlo[8] = "EHLO ";
9 uint64_t mask = 0x8080800302020001;
11 uint64_t a = 0x0000000000090007;
12 uint64_t b = 0x0000000000000000;
13 uint32_t c;
14 uint16_t d;
16 const char e[16] = "LLOaaaaaaaaaaaaa";
17 const char f[16] = "aaaaaaaaaaaaaaHE";
19 /* pshufb mm1/xmm1, mm2/xmm2 */
20 asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0", "mm1");
21 asm volatile ("movq %0, %%mm1" : : "m" (mask));
22 asm volatile ("pshufb %mm1, %mm0");
23 asm volatile ("movq %%mm0, %0" : "=m" (hello));
24 printf("%s\n", hello);
26 /* pshufb mm1/xmm1, m64/m128 */
27 asm volatile ("movq (%0), %%mm0" : : "r" (ehlo) : "mm0");
28 asm volatile ("pshufb %0, %%mm0" : : "m" (mask));
29 asm volatile ("movq %%mm0, %0" : "=m" (hello));
30 printf("%s\n", hello);
32 /* psubsw mm1/xmm1, m64/m128 */
33 asm volatile ("movq %0, %%mm0" : : "r" (a) : "mm0");
34 asm volatile ("phsubsw %0, %%mm0" : : "m" (b));
35 asm volatile ("movq %%mm0, %0" : "=m" (a));
36 printf("%i - %i = %i\n", 9, 7, -(int16_t) a);
38 /* palignr mm1/xmm1, m64/m128, imm8 */
39 asm volatile ("movdqa (%0), %%xmm0" : : "r" (e) : "xmm0");
40 asm volatile ("palignr $14, (%0), %%xmm0" : : "r" (f));
41 asm volatile ("movdqa %%xmm0, (%0)" : : "r" (hello));
42 printf("%5.5s\n", hello);
44 #if 1 /* SSE4 */
45 /* popcnt r64, r/m64 */
46 asm volatile ("movq $0x8421000010009c63, %%rax" : : : "rax");
47 asm volatile ("popcnt %%ax, %%dx" : : : "dx");
48 asm volatile ("popcnt %%eax, %%ecx" : : : "ecx");
49 asm volatile ("popcnt %rax, %rax");
50 asm volatile ("movq %%rax, %0" : "=m" (a));
51 asm volatile ("movl %%ecx, %0" : "=m" (c));
52 asm volatile ("movw %%dx, %0" : "=m" (d));
53 printf("%i = %i\n%i = %i = %i\n", 13, (int) a, 9, c, d + 1);
54 #endif
56 return 0;