cpu: lower baseline 128-bit SSE3 and SSE4.1 floating-point instructions #596
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/602"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T15:11:39Z.
Summary
tools/ffx_version_query.py: lower 22 legacy-encoding 128-bit SSE3/SSE4.1 floating-point instructions for trackedxmm0-xmm2(wide0-wide2):addsubps/pd,haddps/pd,hsubps/pd,movddup,movsldup,movshdup,lddqu,roundps/pd,roundss/sd,dpps,dppd,blendps/pd,blendvps/pd,insertps,extractps. FP arithmetic emits the matching host intrinsics; data movement is byte-level; upper YMM bytes are preserved. MMX, VEX, untracked XMM andmovntdqastay rejected.tests/cpu/sse34_fp.{asm,def,py}: source-built MASM fixture with 33 exports, three-way differential check (native DLL, lifted DLL, independent IEEE-754Fractionreference), NaN/denormal/-0.0 cases, immediate sweeps (all 256insertpsimm8 values, allblendps/blendpdimmediates, 16+1dppdand 18 representativedppsmasks, all four rounding modes plus the MXCSR-select and NO_EXC bits), narrow memory widths (m32/m64/m128 guarded), 4 mutated lifted controls that must mismatch, rejection checks (MMX, VEX,xmm3+,movntdqa), and a CPUID SSE3+SSE4.1 probe that exits 77 on incapable hosts.CMakeLists.txt: registerscpu_aot_sse34_fpwithSKIP_RETURN_CODE 77, same shape as the SSE2 batches.docs/experiments.md: records the forms, the fixture checks and the reproduction commands.Test plan
Commit under test:
3ba5feconcpu-sse34-fp(rebased on currentmain).cmake --build --preset dev --target cpu_sse34_fp_liftedctest --preset dev --no-tests=error -R '^cpu_aot_sse34_fp$' -V→ 1/1 Passed:950 baseline 128-bit SSE3/SSE4.1 FP cases across 33 exports matched native DLL and reference; 4 mutated controls mismatched as requiredlower():ctest --preset dev --no-tests=error -R 'cpu_aot_(sse2_int|sse2_sat_mul|sse41|sse41_int|sse41_extend|sse41_42_misc|string_ops|version_query|wide_arith)'→ 8/8 Passed.Imported from R0Y00/Xbox2Windows. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-22T15:11:47Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T07:30:38Z.
Review: DISMISSED
The improved dot-product reference is useful. The new packed memory path loads into an unaligned host temporary and then runs a register intrinsic, which can hide a guest alignment fault. A source-built native probe on an i9-14900HX (Windows build 26200) gave correct results for aligned
DPPSandHADDPSsources, and both reportedaccess violation reading 0xFFFFFFFFFFFFFFFFat a 4-byte misalignment inside readable storage. Please keep the register forms and the established narrow/unaligned moves, and restrict the packed memory forms unless their native alignment behavior is modeled and independently tested. Keep the existing width and NaN cases. This overlaps #375, so I am keeping the two changes in one review queue.Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T18:40:03Z.
cpu_aot_sse34_fpfails at3ba5fecon an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029,devpreset. The other 113cpu_tests pass, with the usualcpu_aot_crypto_shacapability skip.Native and translated agree; only the
Fractionreference differs. Decoded lanes (imm0xf4: all four products, result in lane 2):0x7fc12345QNaN0xffc54321QNaN0x7f800000+inf0x7f800000+inf0x7f800123SNaN0x3f8000001.00xff800000−inf0x000000000.0(t0+t1)+(t2+t3)with "first NaN operand wins" and returns lane 0's NaN,0x7fc12345.0xffc00000produced by the−inf × 0lane. Which NaN DPPS returns when several lanes are NaN is therefore vendor-dependent, and the reference encodes one vendor's choice. The description does not name the CPU of the passing run. If it was AMD, this would be the Intel/AMD difference.Two related observations:
_mm_dp_ps(...)(out/build/dev/cpu_sse34_fp_lifted.cpp), so it runs the host's own DPPS. Native and translated therefore always agree on DPPS on the same host. The real check is against the reference, and on another vendor the translated result follows that vendor rather than the reference._mm_dp_ps.The head also no longer merges cleanly with
main(git merge-tree).AI-assisted: run and analyzed with Claude Code; outputs copied from the local run.
Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T19:15:05Z.
Confirmed, and thanks for the detailed report. The diagnosis was right: for
dpps_op(arg3=0xf4)the product vector contains multiple NaN producers (0x7fc12345,0x7fc00123quieted sNaN, and0xffc00000from-inf * 0), and the Intel Core i7-6820HQ reduction picks a different legal NaN than the reference model's fixed "first NaN operand wins" order. Native and lifted agreed because the lifted code emits_mm_dp_ps; only the independent reference was over-strict.Fix (pushed in
e2526e1, rebased ontoedc2e54):tests/cpu/sse34_fp.pynow computes an allowable-result set fordpps_op/dppd_op. Disabled product lanes are masked to+0.0, then every operand ordering of each commutative multiply and of each pairwise add in the architectural(t0+t1)+(t2+t3)/t0+t1trees is enumerated. The check requires: native output identical to lifted bit-for-bit, disabled destination lanes exactly+0.0, all enabled lanes holding one identical scalar, and that scalar inside the allowed set. For the reported inputs the set is{0x7fc00123, 0x7fc12345, 0xffc00000, 0xffc54321}, covering both the Skylake observation and the previous AMD result while still rejecting foreign payloads, unquieted sNaNs, disabled-lane leakage, and wrong reductions.ctest --preset dev --no-tests=error -R '^cpu_aot_sse34_fp$' -Vpasses here:950 baseline 128-bit SSE3/SSE4.1 FP cases across 33 exports matched native DLL and reference; 4 mutated controls mismatched as required(AMD Ryzen 7 5800X3D, native==lifted bit-exact). The rebase also resolved theCMakeLists.txt/docs/experiments.md/tools/ffx_version_query.pyconflicts against currentmain.AI-assisted: yes. All reported checks ran locally on the hardware listed.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T13:16:25Z.
New independent evidence for
e2526e1after resolving the current main conflicts locally. On Windows build 26200.9974 (MSVC/ML64 19.51, dev preset), the native and lifted DPPS outputs agree at mask 0xff, but the test rejects their lane-specific NaNs. For a=4523c17f0000807f2301807f000080ff and b=2143c5ff0000807f0000803f00000000 both outputs were 4523c17f4523c17f0000c0ff2301c07f. The current check requires every enabled result lane to have the same payload. Please allow lane-specific quiet NaNs only for the already identified ambiguous multi-producer case, while continuing to compare native and lifted bits, disabled zero lanes and determinate results exactly.I also expanded the original alignment probe with aligned and +4 pointers into readable storage. All 16 packed m128 arithmetic, duplication, rounding, dot-product and blend forms accepted the aligned pointer and raised access violation at +4. LDDQU accepted both. This supports keeping LDDQU and the narrow forms separate from the aligned full-width path. The existing changes request still applies.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T13:29:53Z.
I pushed
3007320to your branch. The full-width legacy SSE3/4.1 memory path checks the actual 16-byte alignment and reuses the existing Windows alignment-fault path. Four new +4 misalignment cases preserve the same native and translated read fault and the untouched output. LDDQU and narrow sources retain the previous behavior. The dot-product reference now checks each enabled lane against the allowed result set while keeping native/lifted equality and disabled-zero bits exact.Windows dev and /O2 each passed the SSE3/4.1 fixture (950 comparisons, four mutations and the four new alignment controls) and the existing CMPXCHG fixture (120 comparisons plus its fault controls). The previous alignment review is resolved on this commit. GitHub CI is pending.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T14:07:10Z.
The Windows rerun passed the SSE and WARP facing checks, but failed in the existing RCX branch fixture. All 7,712 native/translated cases matched before a deliberately mutated zero-count guard let LOOPNE scan past its backing bytes. #858 bounds that scan and keeps all three negative controls, which now pass locally in both dev and release. I’ll refresh this branch and recheck Windows after that fix lands.