cpu: lower SSE3 and SSE4.1 floating-point and data-movement instructions #375
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!375
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/375/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Vonsek on GitHub · 2026-11-21 23:44 UTC · original
Vonsek:ag/cpu-lower-sse3-4-fp→main· +460 −2 · 6 files · 2 commits · closed without mergingChange
movups/movupd) intools/ffx_version_query.py:addsubps,addsubpd,haddps,haddpd,hsubps,hsubpd,movddup,movsldup,movshdup,lddqublendps,blendpd,blendvps,blendvpd,dpps,dppd,roundps,roundpd,roundss,roundsd,extractpsEncodingKind.LEGACYXMM forms, implement exact host-independent ties-to-even/floor/ceil/trunc rounding inround_x86, and reject MXCSR rounding mode (imm8 & 4 != 0).SSE3) and 19 (SSE4.1) before invoking the native fixture (exiting 77 withSKIP_RETURN_CODE 77on hosts without SSE3/SSE4.1).tests/cpu/sse3_4_fp.{asm,def,py}, CMake targetcpu_sse3_4_fp_lifted, CTestcpu_aot_sse3_4_fp, coverage mapping intools/form_coverage.py, and documentation indocs/experiments.md.Verification
cmake --build --preset dev --target cpu_sse3_4_fp_lifted:ValueError: unsupported query operation at 0x1000: movups xmm0,[rcx]cmake --build --preset dev --target cpu_sse3_4_fp_liftedsucceeded with 0 warningsctest --preset dev --no-tests=error -R "^(cpu_aot_sse3_4_fp|cpu_aot_bmi1)$" -V: 2/2 passed (23 SSE3/SSE4.1 floating-point and data-movement cases matched native and translated DLLs+ MXCSR-moderoundpsrejection control).\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py:form coverage checks passedEvidence and follow-up
SSE3-4-grouped mnemonics indocs/coverage/x64_zen2.tsvusing source-built fixtures, gated by a runtime CPUID check.@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:47 UTC · original · edited 2026-11-21 23:54 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
9236fdcℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -395,0 +476,4 @@ftype, lane_size, lanes = ("float", 4, 4) if op == M.DPPS else ("double", 8, 2)stmt = (f"{{ {src_init} {ftype} a[{lanes}], b[{lanes}], s = {ftype}(0); "f"memcpy(a, {dst}.data(), 16); memcpy(b, rhs.data(), 16); "f"for (size_t k=0; k<{lanes}; ++k) {{ if (({imm}u >> (4u + k)) & 1u) s += a[k] * b[k]; }} "@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:54 UTC · original
For inputs with cancellation, the sequential accumulator does not implement DPPS's pairwise reduction
(p0+p1)+(p2+p3). With the fixture's0xD5mask,a=(1e20f,0,-1e20f,1)andb=(1,1,1,1), native DPPS returns(0,0,0,0)while the emitted C++ returns(1,0,1,0); this reproduces in both unoptimized and optimized comparisons on Linux x86-64. Initializing the accumulator to positive zero also makes DPPD lose negative zero when both selected products are negative zero. Emit masked products followed by the architectural reduction tree, rather than accumulating from zero, and add cancellation and signed-zero cases.Useful? React with 👍 / 👎.
@ -395,0 +432,4 @@if i.op1_kind == K.REGISTER and i.op1_register in wide_xmm:src_init = f"std::array<uint8_t,16> rhs; memcpy(rhs.data(), {wide_xmm[i.op1_register]}.data(), 16);"elif i.op1_kind == K.MEMORY:src_init = f"std::array<uint8_t,16> rhs; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), 16);"@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:54 UTC · original
When
ROUNDSS,ROUNDSD, orMOVDDUPuses a memory source, this emits a 16-byte read even though their memory operands are only 4, 8, and 8 bytes respectively. A scalar occupying the last valid bytes before an inaccessible page therefore succeeds natively but can fault in the unoptimized emitted C++; a Linux x86-64 page-boundary comparison reproduces this for all three instructions. Read only the decoded memory operand's width instead of always copying 16 bytes. The new fixture misses this because it uses register sources for these operations.Useful? React with 👍 / 👎.
@ -41,2 +42,4 @@memcpy(reinterpret_cast<void*>(address), &v, sizeof v);}template<class T> T round_x86(T x, unsigned mode) {if (!std::isfinite(x) || x == T(0)) return x;@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:54 UTC · original
For a signaling-NaN source with the normal masked-invalid MXCSR setting, this fast path returns the original signaling bit pattern, whereas SSE4.1 rounding instructions quiet it. For example, native
ROUNDPSwith immediate0x08maps0x7f800001to0x7fc00001, but the emitted helper returns0x7f800001; this reproduces in both unoptimized and optimized comparisons on Linux x86-64. Consequently, the accepted ROUNDPS/PD/SS/SD forms produce incorrect output bytes for these inputs. Handle signaling NaNs explicitly before returning non-finite values and include exceptional-value comparisons in the fixture.Useful? React with 👍 / 👎.
@legacy-code-archaeologist on GitHub · 2026-11-22 19:26 UTC · original
Verified
8510482on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029,devpreset.ctest --preset dev --no-tests=error -R "^cpu_" -j 4passes 81 of 81 on this branch's base.Two notes:
tests/cpu/sse3_4_fp.pyexercisesdpps_op/dppd_oponly with finite inputs; there are no NaN or infinity lanes. In #602 a DPPS case with several NaN products failed on this Intel host because the reference model encodes one vendor's NaN choice, and the translation runs the host's own dot-product instruction. The same case does not arise here yet, but a multi-NaN dot product would need the same vendor-tolerant check.mainatff7f68a(git merge-tree).AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-23 13:43 UTC · original
I rebuilt your original 23 exports at
8510482and translated them with the current #602 candidate (3007320). All 23 positive cases matched the native DLL in an independent MSVC /O2 build, including the legacy MOVUPS/MOVUPD transport and rounding cases. The old MXCSR-selected rejection check was outside that positive comparison because #602 explicitly tests that mode as supported.I am keeping these in the same merge queue. #602 is still open while its Windows check reruns for a separate WARP failure. Your original fixture and the independent Skylake report remain useful cross-checks for the overlapping implementation.
@R0Y00 on GitHub · 2026-11-23 14:37 UTC · original
#602 is now merged. As recorded in the independent comparison above, all 23 positive exports from this branch matched its shared lowering. The Skylake report remains linked here, including the DPPS NaN-selection observation. Closing this overlapping implementation as a duplicate of #602.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:54 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
9236fdc991ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pull request closed