Bug 518220 - Add ROUNDPS, ROUNDSS, ROUNDPD, ROUNDSD SSE4.1 support for x86
Summary: Add ROUNDPS, ROUNDSS, ROUNDPD, ROUNDSD SSE4.1 support for x86
Status: ASSIGNED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Mark Wielaard
URL:
Keywords:
Depends on:
Blocks: 518222
  Show dependency treegraph
 
Reported: 2026-03-27 12:06 UTC by Mark Wielaard
Modified: 2026-05-06 14:22 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Complete x86 ROUNDSS, ROUNDSD support and add testcases (116.86 KB, text/plain)
2026-05-02 21:05 UTC, Mark Wielaard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2026-03-27 12:06:37 UTC
There is ROUNDPS, ROUNDSS, ROUNDPD, ROUNDSD SSE4.1 support on amd64, but not x86.

Note there is partial x86 ROUNDSS (only) support in VEX/priv/guest_x86_toIR.c
Comment 1 Mark Wielaard 2026-05-02 21:05:41 UTC
Created attachment 191989 [details]
Complete x86 ROUNDSS, ROUNDSD support and add testcases

x86 already supported SSE 4.1 ROUNDSS and ROUNDSD instructions like
amd64. But was missing two small fixes.

commit 20277ab2a575ffb50eb4efd58b6a554ffc2927e1 (vex svn r2074)
Handle non-immediate-rounding-mode versions of ROUND{P,S}{S,D}.

commit 779b619c76900dd8d1aa16bb0c693918006019ee (vex svn r2211)
Ignore the precision flag in the ROUND{SS,SD,PS,PD} rounding mode.

Add these and adapt the ROUNDSS and ROUNDSD testcases so they work on
both amd64 and x86. Move get_mxcsr, set_mxcsr, get_sse_roundingmode
and set_sse_roundingmode from sse4-64.c to sse4-common.h (and add x86
variants). Move ROUNDSD and ROUNDSS test function and make them use
XMMREG_DST instead of xmm11 (which isn't available on x86).

Add testcase output for test_ROUNDSD_w_immediate_rounding(),
test_ROUNDSS_w_immediate_rounding(), test_ROUNDSD_w_mxcsr_rounding()
and test_ROUNDSS_w_mxcsr_rounding() to sse4-x86.stdout.exp.
Comment 2 Alexandra Hajkova 2026-05-05 14:39:03 UTC
(In reply to Mark Wielaard from comment #1)
> Created attachment 191989 [details]
> Complete x86 ROUNDSS, ROUNDSD support and add testcases
> 
> x86 already supported SSE 4.1 ROUNDSS and ROUNDSD instructions like
> amd64. But was missing two small fixes.
> 
> commit 20277ab2a575ffb50eb4efd58b6a554ffc2927e1 (vex svn r2074)
> Handle non-immediate-rounding-mode versions of ROUND{P,S}{S,D}.
> 
> commit 779b619c76900dd8d1aa16bb0c693918006019ee (vex svn r2211)
> Ignore the precision flag in the ROUND{SS,SD,PS,PD} rounding mode.
> 
> Add these and adapt the ROUNDSS and ROUNDSD testcases so they work on
> both amd64 and x86. Move get_mxcsr, set_mxcsr, get_sse_roundingmode
> and set_sse_roundingmode from sse4-64.c to sse4-common.h (and add x86
> variants). Move ROUNDSD and ROUNDSS test function and make them use
> XMMREG_DST instead of xmm11 (which isn't available on x86).
> 
> Add testcase output for test_ROUNDSD_w_immediate_rounding(),
> test_ROUNDSS_w_immediate_rounding(), test_ROUNDSD_w_mxcsr_rounding()
> and test_ROUNDSS_w_mxcsr_rounding() to sse4-x86.stdout.exp.

Looks perfect to me ;).
Comment 3 Mark Wielaard 2026-05-06 14:22:37 UTC
(In reply to Alexandra Hajkova from comment #2)
> Looks perfect to me ;).

Thanks, pushed as commit 2b76d5e545261f77a2302d106d3cd11a700b0055

Next up ROUNDPS and ROUNDPD.