From 3272aa3f0858604b8a43298ea79b33a675d33049 Mon Sep 17 00:00:00 2001 From: LC Date: Wed, 17 Jun 2026 00:36:33 -0400 Subject: [PATCH] [SVE256] Handle SSE insertions for ROUNDPD/ROUNDPS See #3799 --- .../Core/OpcodeDispatcher/Vector.cpp | 2 +- unittests/ASM/SSELanePreservation/roundpd.asm | 25 +++++++++++++++++++ unittests/ASM/SSELanePreservation/roundps.asm | 25 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 unittests/ASM/SSELanePreservation/roundpd.asm create mode 100644 unittests/ASM/SSELanePreservation/roundps.asm diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp index 3b2d19e37..ee84ad248 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp @@ -4019,7 +4019,7 @@ void OpDispatchBuilder::VectorRound(OpcodeArgs, IR::OpSize ElementSize) { const uint64_t Mode = Op->Src[1].Literal(); Src = VectorRoundImpl(OpSizeFromDst(Op), ElementSize, Src, Mode); - StoreResultFPR(Op, Src); + StoreResult_WithAVXInsert(VectorOpType::SSE, RegClass::FPR, Op, Src); } void OpDispatchBuilder::AVXVectorRound(OpcodeArgs, IR::OpSize ElementSize) { diff --git a/unittests/ASM/SSELanePreservation/roundpd.asm b/unittests/ASM/SSELanePreservation/roundpd.asm new file mode 100644 index 000000000..808b2b9d9 --- /dev/null +++ b/unittests/ASM/SSELanePreservation/roundpd.asm @@ -0,0 +1,25 @@ +%ifdef CONFIG +{ + "HostFeatures": ["AVX"], + "RegData": { + "XMM0": ["0x43cc1ad6970b4549", "0x8000000000000000", "0xccdbcfc31f3ff0f3", "0x108390defebac4be"], + "XMM1": ["0xc4be43cc1ad6970b", "0x4549bd7eb46a1278", "0", "0"], + "XMM2": ["0xc4be43cc1ad6970b", "0x4549bd7eb46a1278", "0xf793ef673dac6e4c", "0xbb7b5b3d85d34271"] + } +} +%endif + +vmovaps ymm0, [rel .data] +vmovaps ymm1, [rel .data + (1 * 32)] +vmovaps ymm2, [rel .data + (2 * 32)] + +roundpd xmm0, xmm1, 0b00 +vroundpd xmm1, xmm2, 0b00 + +hlt + +align 32 +.data: +dq 0xfdecd28fab3fa4a5, 0x7d7ccd8836d09fc2, 0xccdbcfc31f3ff0f3, 0x108390defebac4be +dq 0x43cc1ad6970b4549, 0xbd7eb46a1278f793, 0xef673dac6e4cbb7b, 0x5b3d85d342718be9 +dq 0xc4be43cc1ad6970b, 0x4549bd7eb46a1278, 0xf793ef673dac6e4c, 0xbb7b5b3d85d34271 diff --git a/unittests/ASM/SSELanePreservation/roundps.asm b/unittests/ASM/SSELanePreservation/roundps.asm new file mode 100644 index 000000000..125d2d524 --- /dev/null +++ b/unittests/ASM/SSELanePreservation/roundps.asm @@ -0,0 +1,25 @@ +%ifdef CONFIG +{ + "HostFeatures": ["AVX"], + "RegData": { + "XMM0": ["0x43cc000080000000", "0x8000000000000000", "0xccdbcfc31f3ff0f3", "0x108390defebac4be"], + "XMM1": ["0xc4be400000000000", "0x4549c00080000000", "0", "0"], + "XMM2": ["0xc4be43cc1ad6970b", "0x4549bd7eb46a1278", "0xf793ef673dac6e4c", "0xbb7b5b3d85d34271"] + } +} +%endif + +vmovaps ymm0, [rel .data] +vmovaps ymm1, [rel .data + (1 * 32)] +vmovaps ymm2, [rel .data + (2 * 32)] + +roundps xmm0, xmm1, 0b00 +vroundps xmm1, xmm2, 0b00 + +hlt + +align 32 +.data: +dq 0xfdecd28fab3fa4a5, 0x7d7ccd8836d09fc2, 0xccdbcfc31f3ff0f3, 0x108390defebac4be +dq 0x43cc1ad6970b4549, 0xbd7eb46a1278f793, 0xef673dac6e4cbb7b, 0x5b3d85d342718be9 +dq 0xc4be43cc1ad6970b, 0x4549bd7eb46a1278, 0xf793ef673dac6e4c, 0xbb7b5b3d85d34271