include <stdio.h> int main() { int t; int one[1] = {1}; asm volatile( "pxor %%xmm0,%%xmm0\n\t" "movd %1,%%xmm1\n\t" "pmaxsd %%xmm1,%%xmm0\n\t" "movd %%xmm0,%0\n\t" : "=r"(t) : "m"(one)); printf(" %d\n", t); return 0; } It'll work fine on 64-bit and if you compile it on 32-bit it will work fine but Valgrind will complain about illegal instruction
most of SSE4.1 should be implemented for amd64, but not for x86 none/tests/amd64/sse4-64.c has a lot more test cases than none/tests/x86/sse4-x86.c so that might be a good way to start (add some tests from amd64 to x86 and then lift the implementation).
Created attachment 186499 [details] patch Let's refactor the current code a bit to make it easier to use existing amd64 code for x86 tests.
Created attachment 186695 [details] patch sse4-common.h: make changes to make test_PMAXSD usable for 32bit Modify DO_imm_r_r macro called by test_PMAXSD to use xmm7 register when testing on 32bit.
Created attachment 186696 [details] patch Add pmaxsd support for x86 32 bit Support pmaxsd instruction in guest_x86_toIR.c and host_x86_isel.c and modify the none/tests/x86/sse4-x86.stdout.exp to match pmaxsd support.
(In reply to Alexandra Hajkova from comment #4) > Created attachment 186696 [details] > patch > > Add pmaxsd support for x86 32 bit > > Support pmaxsd instruction in guest_x86_toIR.c and host_x86_isel.c > and modify the none/tests/x86/sse4-x86.stdout.exp to match pmaxsd > support. This looks very nice. I would also handle PMINSD in the guest decoder and add test_PMINSD, since you already have it in the instruction selector. Nitpick, some extra whitespace in VEX/priv/guest_amd64_toIR.c The patch buildup is nice too. First pulling out the common code. Then making it usable for building on 32bit. Then implementing the instructions and testing them.
Created attachment 187193 [details] patch
Created attachment 187194 [details] patch
These three patches look good. Just needs a NEWS entry. Please apply.