cpu: lower single-element string transfers without REP #594

Merged
Joacoorandom merged 4 commits from upstream-pr/600 into main 2026-11-22 20:01:49 +00:00
Joacoorandom commented 2026-11-22 15:02:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-22T15:02:17Z.


Change

Accept single-element MOVSB/MOVSW/MOVSD/MOVSQ and STOSB/STOSW/STOSD/STOSQ in the control-flow CPU lifter. Without REP, execute exactly one transfer and preserve RCX, including when RCX is zero. Both forward and backward directions use the existing direction proof; arithmetic flags and nonvolatile registers retain their contracts.

Depends on #599 and #598; #597 is merged. Rebased the three remaining increments on current main: fill 461a4f5, direction 2b74c4c, and single-element 05e4a0a. Review the single-element increment in 05e4a0a. The PR diff still includes #598 and #599 until those dependencies merge. Original Windows verification predates the rebase.

Verification

Commit b4e55cb. Native Windows 11 26300.9974, MSVC/ML64 19.44.35230, Python 3.12.8.

cmake --build out/native --target cpu_switch_strings_lifted cpu_switch_strings_lifted_o2 cpu_switch_strings_mutants cpu_string_probe cpu_guarded_call cpu_switch_original_lifted cpu_switch_swapped_lifted cpu_register_probe cpu_flag_conditions_lifted cpu_frame_lifted cpu_calls_lifted cpu_call_entries_lifted --parallel 4
ctest --test-dir out/native --no-tests=error -R "^cpu_aot_(switch_strings|jump_tables|flag_conditions|stack_frames|direct_calls|call_entries)$" -V

All six selected tests passed. The cumulative string comparison now covers thirty-five exports and 13,656 native/AOT/reference cases, plus 63 access-violation comparisons, including /O2. This increment adds sixteen single-element exports across copy/store, four widths and two directions. Counts 0/1/2/3/7/16/31 must remain unchanged; the operation still executes at zero. Full buffers and trace guards, final pointers, carry flags and physical RSI/RDI/DF are checked. All rejection controls and three compiled semantic mutations remain effective.

Linux checks passed:

python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check

Evidence and follow-up

Original MIT fixtures and byte-array reference, reusing the earlier comparison and harness. No proprietary inputs or external project source. Address-size overrides, segment prefixes, REPNE, LODS, SCAS and CMPS remain rejected in this profile. No exception-resumption, native REP fault-register, concurrency or throughput equivalence is claimed. README and experiment notes updated. AI-assisted.

Checklist

  • One reviewable behavior.
  • Exact checks and results included.
  • Negative controls retained.
  • README and experiments updated.
  • No game files, distribution links or secrets.

Conflict-resolution update (2026-11-22)

Rebased onto current upstream main after #597 was merged, preserving each increment in stack order. Local checks passed: form_coverage_check.py, docs_links_check.py, bidi_controls_check.py, cpu/lower_prefixes_check.py, plus git diff --check. Previous native-Windows results describe the original commits; the official Windows CI on the new head provides independent revalidation. No workflow or unrelated files were edited.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543909493 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/600). Originally posted by [Joacoorandom](https://github.com/Joacoorandom) on 2026-11-22T15:02:17Z. --- ## Change Accept single-element MOVSB/MOVSW/MOVSD/MOVSQ and STOSB/STOSW/STOSD/STOSQ in the control-flow CPU lifter. Without REP, execute exactly one transfer and preserve RCX, including when RCX is zero. Both forward and backward directions use the existing direction proof; arithmetic flags and nonvolatile registers retain their contracts. **Depends on #599 and #598; #597 is merged.** Rebased the three remaining increments on current `main`: fill `461a4f5`, direction `2b74c4c`, and single-element `05e4a0a`. Review the single-element increment in `05e4a0a`. The PR diff still includes #598 and #599 until those dependencies merge. Original Windows verification predates the rebase. ## Verification Commit `b4e55cb`. Native Windows 11 26300.9974, MSVC/ML64 19.44.35230, Python 3.12.8. ```powershell cmake --build out/native --target cpu_switch_strings_lifted cpu_switch_strings_lifted_o2 cpu_switch_strings_mutants cpu_string_probe cpu_guarded_call cpu_switch_original_lifted cpu_switch_swapped_lifted cpu_register_probe cpu_flag_conditions_lifted cpu_frame_lifted cpu_calls_lifted cpu_call_entries_lifted --parallel 4 ctest --test-dir out/native --no-tests=error -R "^cpu_aot_(switch_strings|jump_tables|flag_conditions|stack_frames|direct_calls|call_entries)$" -V ``` All six selected tests passed. The cumulative string comparison now covers thirty-five exports and 13,656 native/AOT/reference cases, plus 63 access-violation comparisons, including /O2. This increment adds sixteen single-element exports across copy/store, four widths and two directions. Counts 0/1/2/3/7/16/31 must remain unchanged; the operation still executes at zero. Full buffers and trace guards, final pointers, carry flags and physical RSI/RDI/DF are checked. All rejection controls and three compiled semantic mutations remain effective. Linux checks passed: ```sh python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py git diff --check ``` ## Evidence and follow-up Original MIT fixtures and byte-array reference, reusing the earlier comparison and harness. No proprietary inputs or external project source. Address-size overrides, segment prefixes, REPNE, LODS, SCAS and CMPS remain rejected in this profile. No exception-resumption, native REP fault-register, concurrency or throughput equivalence is claimed. README and experiment notes updated. AI-assisted. ## Checklist - [x] One reviewable behavior. - [x] Exact checks and results included. - [x] Negative controls retained. - [x] README and experiments updated. - [x] No game files, distribution links or secrets. ### Conflict-resolution update (2026-11-22) Rebased onto current upstream `main` after #597 was merged, preserving each increment in stack order. Local checks passed: `form_coverage_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `cpu/lower_prefixes_check.py`, plus `git diff --check`. Previous native-Windows results describe the original commits; the official Windows CI on the new head provides independent revalidation. No workflow or unrelated files were edited.
upstream-sync closed this pull request 2026-11-24 06:43:52 +00:00
legacy-code-archaeologist commented 2026-11-24 06:48:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T17:34:43Z.


Verification of b4e55cb on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, dev preset. I tested this head separately from the rest of the series, see #598:

ctest --preset dev --no-tests=error -R "^cpu_" -j 4
100% tests passed, 0 tests failed out of 114
cpu_aot_switch_strings:
9 whole-PE rejection controls and 5 unsupported forms rejected
13656 native/AOT/reference cases passed: bytes, guards, remaining count, pointers, CF, RSI/RDI and DF
63 nonzero-count access violations preserved, including /O2
3 compiled /O2 semantic mutations detected: ignored DF, memmove overlap, truncated REP count

Like #598, this head no longer merges cleanly with main now that #597 has landed.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7082944929 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/600#issuecomment-7082944929). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T17:34:43Z. --- Verification of `b4e55cb` on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, `dev` preset. I tested this head separately from the rest of the series, see #598: ```text ctest --preset dev --no-tests=error -R "^cpu_" -j 4 100% tests passed, 0 tests failed out of 114 cpu_aot_switch_strings: 9 whole-PE rejection controls and 5 unsupported forms rejected 13656 native/AOT/reference cases passed: bytes, guards, remaining count, pointers, CF, RSI/RDI and DF 63 nonzero-count access violations preserved, including /O2 3 compiled /O2 semantic mutations detected: ignored DF, memmove overlap, truncated REP count ``` Like #598, this head no longer merges cleanly with `main` now that #597 has landed. AI-assisted (Claude Code).
legacy-code-archaeologist commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T19:17:31Z.


Re-checked the rebased head 05e4a0a on the same Skylake host. ctest --preset dev --no-tests=error -R "^cpu_" -j 4 reports 100% passed (118/118). Now that #599 has landed, git merge-tree reports a conflict with main at edc2e54 again, so the branch will need one more update.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084273321 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/600#issuecomment-7084273321). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T19:17:31Z. --- Re-checked the rebased head `05e4a0a` on the same Skylake host. `ctest --preset dev --no-tests=error -R "^cpu_" -j 4` reports 100% passed (118/118). Now that #599 has landed, `git merge-tree` reports a conflict with `main` at `edc2e54` again, so the branch will need one more update. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!594
No description provided.