x64_recomp: SSE/SSE2 scalar floating-point and XMM move/bitwise emitters (X64-RECOMP-SSE-SCALAR) #1202
Closed
leonida/mandy
quietfold wants to merge 0 commits from
feat/x64-recomp-sse-scalar into main
pull from: feat/x64-recomp-sse-scalar
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1202
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/x64-recomp-sse-scalar"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: X64-RECOMP-SSE-SCALAR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143077050)
What and why
Advances Next Step #2 of
docs/mobile.mdby adding legacy0FSSE/SSE2 scalar floating-point, conversion, comparison, and 128-bit XMM move/bitwise decoding and arm64 emission totools/x64_recomp.py(independent of#1174and conflict-free with all openx64_recompPRs).0FSSE/SSE2 decoder (_OF_SSE): decodesxmm0–xmm15(("x", reg, size)), width specsx(16B) andy(4/8B viaREX.W, ignoring0x66), mandatoryF2/F3precedence over66, and keeps unprefixed MMX encodings as unhandled"simd".Asm): addsfldr/fstr(S/D/Q),fadd/fsub/fmul/fdiv/fsqrt,fcmp/fcsel,fmov_r/fmov_to_fp/fmov_to_gpr,fcvt_s2d/fcvt_d2s,scvtf/fcvtzs/fcvtns,vins0,vand16b/vbic16b/vorr16b/veor16b, plus EL1CPACR_EL1.FPENenable inbuild_test_kernelfor bare-metal QEMU runs.XMAP:xmm0–xmm15->v0–v15, scratchv28–v30):add/sub/mul/div/sqrt/min/max(ss/sd),cvt*, and registermovss/movsdwrite lane 0 viainsso upper XMM bits are preserved; memorymovss/movsdandmovd/movqzero-extend to 128 bits.minss/minsd/maxss/maxsdimplement exact x86 NaN and±0.0second-operand rules viafcmp+fcsel(mi/gt) while preserving liveNZCV.ucomis*/comis*(FCMP_KIND) map all 16 x86 conditions across ordered and unordered (PF/ZF/CF,OF=SF=AF=0) results on both the arm64NZCVfast path and materializedCTX_EFLAGS(includingsetcc,cmov,pushf,lahf,adc/sbb/cmc, and interveninginc/dec).cvttss2si/cvttsd2si/cvtss2si/cvtsd2si, 32/64-bit) return x86 integer indefinite (INT32_MIN/INT64_MIN) forNaNand overflow (including2147483647.5forcvtsd2sivscvttsd2si) while preserving liveNZCV.movaps/movups/movapd/movupd/movdqa/movdqu) and bitwise ops (xorps/xorpd/pxor,andps/andpd/pand,andnps/andnpd/pandnas(~dst) & src,orps/orpd/por)._ctx_jcc_regemittedtst_i(w, EF_CF | EF_ZF)(0x41is not a valid arm64 bitmask immediate) on cross-blockja/jbe/seta/setbe; replaced withmovz+tst_r._classifytaggedlahf/sahfaskind="conv"instead of"alu", making their_emit_aluhandler unreachable.tests/test_x64_recomp_sse.py): 16 tests covering decoding, LLVM 21–verified arm64 FP/SIMD encodings, translation/liveness, and 8 end-to-end execution tests (SSEExecTests, which run automatically with the Mach-O runner once#1174lands or under QEMU).Tested
main:python3 -I tests/test_x64_recomp_sse.py -v(8 cross-platform passed, 8 exec cleanly skipped without QEMU),tests/test_x64_recomp.py,tests/test_recomp_census.py,tests/test_ci_registration.py,tests/test_text_write_line_endings.py,tests/test_tool_startup.py, all 11tests/test_docs_*.py,tests/test_i18n_index.py,compileall,make_game.py --help,check_no_game_data.py: all passed.#1174in a scratch checkout):tests/test_x64_recomp_sse.py16/16 passed (all 8SSEExecTestsexecuted natively) andtests/test_x64_recomp.py46/46 passed.git apply --check) against openx64_recompPRs#847,#950,#1120,#1121, and#1174.GPUs tested: n/a (CPU x86-64 -> arm64 recompiler; tested natively on Apple M5 arm64, macOS 27.2.1)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Independent run with QEMU. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, QEMU 11.1.3 from Homebrew. I merged
mainat61732aca1into the branch locally (980 commits behind, no conflicts). Head tested:e61deb5b1.I found nothing wrong. 3,012 of 3,013 generated checks match Python's float arithmetic, and the one that does not is
main'smov r64, -1, not this change.python -I tests/test_x64_recomp_sse.py: 16/16 under QEMU. The file callsx.run_resultand gates onHAS_QEMU, so its exec tests really run.tests/test_x64_recomp.py33/33,tests/test_recomp_census.py11/11. Full standalone suite: 514 run, 509 pass; the 5 that fail are the 5 that fail onmain(the usual 4 plustest_image_load_typed, red since #2098).Beyond the file, generated cases under QEMU, each compared against a Python model (operands loaded with
movq xmm, r64, result read back withmovq r64, xmm):addss/subss/mulss/divss/minss/maxssover 14 single-precision values (±0, 1, 1.5, −2.25, near-max, the smallest denormal, ±inf, a quiet NaN, 2^24, 0.1, values around 2^31) against 8 partners each, and thesdforms over 15 doubles. Each check is the whole low qword, so for thessforms the upper 32 bits of the destination must survive. Where the model says NaN, any NaN is accepted;min/maxare checked bit-exactly, including "return the second operand" for NaN and for equal operands.sqrtss,sqrtsd,cvtss2sd,cvtsd2ssover the same values.cvtsi2ss,cvtsi2sdfromecxandrcx, including 16777217 and 2^53+1 (rounding) and both integer limits.cvttss2si,cvtss2si,cvttsd2si,cvtsd2siinto 32- and 64-bit registers: truncation against round-half-to-even on 0.5, 1.5, 2.5, 3.5, the 32-bit boundary cases 2147483647.4, 2147483647.5 and −2147483648.5, and the integer-indefinite result for NaN, ±inf and out-of-range values.ucomiss,comiss,ucomisd,comisdover 7×7 operand pairs including NaN on either side, each followed by one ofsetb/setae/sete/setne/setbe/seta/setp/setnp.The single mismatch:
cvtsi2sd xmm0, rcxwith rcx loaded by48 b9 ff ff ff ff ff ff ff fftimed out.mov rcx, -1in that imm64 form hangs onmaintoo, with no SSE involved (Asm.li(-1), which #1339 and #1205 both fix). With rcx set to −1 byxor ecx, ecx; dec rcxthe samecvtsi2sdgivesbff0000000000000, which is right.Not tested: the packed and bitwise 128-bit forms, memory operands, non-default MXCSR rounding modes and the exception flags, the signalling difference between
comissanducomiss, and which NaN payload comes back from arithmetic. No game files used. AI-assisted.Hi @IlyassRS3, thanks for this pull request. It currently conflicts with
main(conflicting file(s):tools/x64_recomp.py), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).