Bug 512873

Summary: Add SSE4.1 min/max instructions for x86 32 bit
Product: [Developer tools] valgrind Reporter: Alexandra Hajkova <ahajkova>
Component: generalAssignee: Alexandra Hajkova <ahajkova>
Status: RESOLVED FIXED    
Severity: normal CC: mark, mueller
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: patch

Description Alexandra Hajkova 2025-12-02 16:19:09 UTC
x86 32 bit lacks the support for pmaxsb, pminsb, pmaxuw, pminuw, pmaxud and pminud instructions
Comment 1 Alexandra Hajkova 2025-12-02 16:19:25 UTC
Created attachment 187308 [details]
patch
Comment 2 Alexandra Hajkova 2025-12-02 16:19:42 UTC
    Add SSE4.1 min/max instructions for x86 32 bit
    
    Support pmaxsb, pminsb, pmaxuw, pminuw, pmaxud and pminud instructions
    in guest_x86_toIR.c and host_x86_isel.c. Move test functions from
    amd64/sse4-64.c to sse4-common.h and update none/tests/x86/sse4-x86.c
    and sse4-x86.stdout.exp to test all min/max instructions.
Comment 3 Mark Wielaard 2025-12-02 17:09:18 UTC
To keep the .exp diff smaller it would be nice to add the new tests at the end.
Comment 4 Mark Wielaard 2025-12-03 12:28:41 UTC
Please add the bug number and summary to NEWS and https://bugs.kde.org/show_bug.cgi?id=512873 at the end of the commit message.

The amd64 variant has a /* FIXME: this needs an alignment check */ and the intel sse4 manual says Exceptions #GP(0) If a memory operand is not aligned on a 16-byte boundary.  But apparently this hasn't been a real issue on amd64 either. Probably no program relies on having an exception raised on non-aligned memory access. which kind of makes sense... Maybe do add a similar comment though.

The code generation is pretty generic, same as for amd64 case.

The tests look ok, although I would reorder the test to make the .exp diff smaller.

Please feel free to push with (or without) those changes.
Comment 5 Mark Wielaard 2025-12-03 12:55:02 UTC
*** Bug 476978 has been marked as a duplicate of this bug. ***
Comment 6 Mark Wielaard 2025-12-09 15:57:50 UTC
commit fb25ce838c953c010883e6bc309fc672a78073e1
Author: Alexandra Hájková <ahajkova@redhat.com>
Date:   Tue Dec 2 11:06:58 2025 -0500

    Add SSE4.1 min/max instructions for x86 32 bit

    Support pmaxsb, pminsb, pmaxuw, pminuw, pmaxud and pminud instructions
    in guest_x86_toIR.c and host_x86_isel.c. Move test functions from
    amd64/sse4-64.c to sse4-common.h and update none/tests/x86/sse4-x86.c
    and sse4-x86.stdout.exp to test all min/max instructions.

    BZ: https://bugs.kde.org/show_bug.cgi?id=512873