Repository navigation
Console CPU instructions: fix ClzeroLoop ModRM check and loop semantics - #290
Merged
Merged
Conversation
Decode ClzeroLoop only when the trailing cmp is register-register against rax ((modrm & 0xC7) == 0xC0) and end_reg != rax, so memory compares or compares on other registers fall back to stepping the single clzero. In emulate_console_only, align the zeroed range to 64-byte cache lines, round the iteration count up to full 64-byte steps, update EFLAGS for cmp rax, end, and fall back to stepping the single clzero (len - 9) when end <= start, the range overflows/exceeds the fast-forward bound, or the full span is not writable. Part of ivall#278. Assisted-by: Antigravity (Gemini 4 Neon)
T-Crypt
added a commit
to T-Crypt/bathyal
that referenced
this pull request
Nov 23, 2026
|
Tested Pass: 653 passed, 0 failed, 40 ignored. GPU skips: the same 2 as on Run and written with Claude Code (Claude Opus 5.5). |
|
Independent static code & x86-64 ISA audit of Summary: Looks clean(Note: overlaps with #295, which also addresses #278.)
(AI-assisted) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes items 1 and 2 of #278 (
ClzeroLoopdecoder false-positive and loop emulation semantics).insn::decodepreviously matched[48|4C] 39 <modrm> 72 F4without checking(modrm & 0xC7) == 0xC0, allowing non-raxor memorycmpforms to decode asClzeroLoop. Ineh::emulate_console_only,ClzeroLoopalso skipped 64-byte cache-line alignment, zeroed partial bytes instead of full 64-byte steps whenend - startwas not a multiple of 64, skipped the firstclzerowhenend <= startwhile still overwritingctx.Rax = end, and leftctx.EFlagsstale.Overlap note: touches
crates/xcl/src/insn.rsandcrates/xcl/src/eh.rs(same files as #234, disjoint hunks).What is in it
crates/xcl/src/insn.rs: require(modrm & 0xC7) == 0xC0andend_reg != 0forClzeroLoop, with negative decoder tests (cmp rdx, rcx,cmp [rax], rdx,cmp rax, rax).crates/xcl/src/eh.rs: alignClzeroLoopto 64-byte lines, advanceRaxin 64-byte steps, update arithmeticEFlagsviacmp_eflags, and fall back to stepping the singleclzero(len - 9) whenend <= startor the full span cannot be fast-forwarded; adds unit tests forcmp_eflagsand aligned/unaligned/end <= startClzeroLoopcases.Tested
26300), Intel Core i9-9900K (Coffee Lake, pre-Ice Lake — noCLZERO/CLWB), AMD Radeon RX 6800 (16337 MiB VRAM, driver32.0.21045.29003; notesmoke.ps1's WMI query prints the first non-Basic adapterParsec Virtual Display Adapter, while XCL renders on the RX 6800),rustc 1.100.0, DXC1.9.2602.17(debugfor tests,releasefor smoke runs).XCL_REQUIRE_GPU=wave64,mesh+.\scripts\test.ps1: 653 passed, 0 failed, 40 ignored, 0 GPU skipped (xcllib: 613 passed / 20 ignored; integration/e2e: 40 passed / 20 ignored;XCL_SAMPLE_*unset).YouKnowWho): confirmedClzeroLoop { end_reg: 10 }ran on i9-9900K inxcl.logwith 0 crashes and 0 device removals.Regression run
Both runs below used the same warmed shader cache on
YouKnowWho(60 s):main(9ab7d763197c):PR head (
9e9551b0ec19):Not tested
XCL_SAMPLE_*unset).AI use