cpu: lower forward MOVS and STOS string instructions with REP #370
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!370
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/370/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?
@denn0x on GitHub · 2026-11-21 23:38 UTC · original
denn0x:cpu/string-moves→main· +306 −0 · 7 files · 1 commits · closed without mergingChange
This advances integer-lifter coverage for CPU code: compilers emit
rep movsandrep stosfor inlinememcpyandmemsetand for struct copies. It touches only the sharedlowerdispatch intools/ffx_version_query.py. The new branch keys onMEMORY_ESRDIoperands, so it cannot catch the SSEmovsd. No open PR claims string instructions (#326 ismovsx, #364 ispmovsx/pmovzx), and no prerequisite PR is needed.movsb,movsw,movsd,movsq,stosb,stosw,stosd,stosq, with and withoutrep:memmove.repcounts RCX down to zero. RSI and RDI advance by the element size. Flags are unchanged.cld: lowers to nothing, because the Windows x64 ABI enters with DF clear and only forward strings are lowered.std(backward strings);repneon a move or store;67prefix, ESI/EDI);cmps,scas,lods;movsd, which shares the mnemonic but has register operands.Tests
tests/cpu/string_ops.asm: ten MASM exports.repforms of all eight instructions, plus onemovsqand onestosdwithoutrep.(dst, src_or_value, count)and returns((final RCX << 20) + RSI advance) << 20 + RDI advance, so the counter and both pointer advances are observed as well as memory.tests/cpu/string_ops.py: compares the native DLL, the translated DLL and an independent sequential Python model, on the full 512-byte buffer and the return value.memmoveof the same range, so a block-copy lowering cannot pass.repne movsb,rep movsbandstosbwith a67prefix, FSmovsb,std,repe cmpsb,lodsb,repne scasband SSEmovsd xmm0, xmm1, each with its exact diagnostic.tools/form_coverage.pymapsstring_opstocpu_aot_string_ops, and x64 coverage goes from 55 of 948 forms on9bdbb20to 64 atbd00df2(the eight string forms pluscld), measured withtools/form_coverage.pyover the JUnit ofctest --preset dev -R '^cpu_'.Verification
Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, Python 3.13.14 with iced-x86 1.21.0. Commit
bd00df2(rebased on9bdbb20).Mutation check (local, reverted): lowering
rep movsas a singlememmovefails at the first forward-overlap case:Full suite (
ctest --preset dev --no-tests=error), rebased on9bdbb20:bvh_wave64_warp,wave_shuffle_warp), 1 failed. ctest prints99% tests passed, 1 tests failed out of 147because it counts the skips as not failed.gpu_alias_lookup_writes_hardwarefails on the RX 9070 XT (driver 32.0.32015.7029). It is a GPU atomics test that arrived with #332, and this change does not touch it. I reported it with measurements in #369.Before the rebase, on
bc24dfd, the suite gave 145 passed and the same two skips, with no failures. All 43cpu_tests pass atbd00df2.tests/form_coverage_check.pypasses.Checklist
docs/experiments.mdis updated.AI-assisted (Claude Code).
@denn0x on GitHub · 2026-11-21 23:42 UTC · original
Closing as a duplicate of #368, which lowers the same forward
movs/stosforms and also coverslods,scas,cmpsandstd. Sorry for the noise.Pull request closed