cpu: cover eight AVX2 lane, blend and cross-lane permute lowerings #662

Merged
Leyukaka merged 1 commit from upstream-pr/668 into main 2026-11-22 19:14:44 +00:00
Leyukaka commented 2026-11-22 18:40:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T18:40:32Z.


Change

This closes eight coverage gaps in the AVX2 lane, blend and cross-lane permute lowering of tools/ffx_version_query.py. Each was a one-line mutation that passed every cpu_ test on main. Only the AVX2 fixture (tests/cpu/avx2_permutes.{asm,def,py}) and its export count in docs/experiments.md change; the translator does not.

Six new cases cover the eight mutations:

New case Mutations it covers
vextracti128 xmm0, ymm0, 2, then the full ymm0 is stored lane chosen from more than bit 0; upper 128 bits not cleared
vinserti128 ymm0, ymm1, xmm2, 2 (register source) lane chosen from more than bit 0; register source read from the first operand
vpblendd ymm0, ymm1, ymm2, 1 mask bits 0 and 2 swapped
vperm2i128 ymm0, ymm1, ymm2, 38h (zeroed low lane) low selector masked to 3 bits
vpermd with an index of 6 in lane 0 index 6 read as 4
vpermq ymm0, ymm1, 4 immediate bit 2 ignored

Every existing case is unchanged, and run2/run3 compare all 32 output bytes.

Verification

On 26fedf7 (branch on f1f95cf), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, on an AVX2-capable host:

ctest --preset dev --no-tests=error -j 4

All 295 tests pass.

Each mutation was applied to tools/ffx_version_query.py one at a time, and all cpu_ tests were run. On main, all of them passed for each mutation. A control that made vextracti128 always take the low lane was caught by cpu_aot_avx2_permutes, so the run does detect a broken translator. On this branch, each of the eight mutations fails cpu_aot_avx2_permutes.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability changed; the export count is updated.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6546203044 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/668). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T18:40:32Z. --- ## Change This closes eight coverage gaps in the AVX2 lane, blend and cross-lane permute lowering of `tools/ffx_version_query.py`. Each was a one-line mutation that passed every `cpu_` test on `main`. Only the AVX2 fixture (`tests/cpu/avx2_permutes.{asm,def,py}`) and its export count in `docs/experiments.md` change; the translator does not. Six new cases cover the eight mutations: | New case | Mutations it covers | |---|---| | `vextracti128 xmm0, ymm0, 2`, then the full `ymm0` is stored | lane chosen from more than bit 0; upper 128 bits not cleared | | `vinserti128 ymm0, ymm1, xmm2, 2` (register source) | lane chosen from more than bit 0; register source read from the first operand | | `vpblendd ymm0, ymm1, ymm2, 1` | mask bits 0 and 2 swapped | | `vperm2i128 ymm0, ymm1, ymm2, 38h` (zeroed low lane) | low selector masked to 3 bits | | `vpermd` with an index of 6 in lane 0 | index 6 read as 4 | | `vpermq ymm0, ymm1, 4` | immediate bit 2 ignored | Every existing case is unchanged, and `run2`/`run3` compare all 32 output bytes. ## Verification On `26fedf7` (branch on `f1f95cf`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, on an AVX2-capable host: ```text ctest --preset dev --no-tests=error -j 4 ``` All 295 tests pass. Each mutation was applied to `tools/ffx_version_query.py` one at a time, and all `cpu_` tests were run. On `main`, all of them passed for each mutation. A control that made `vextracti128` always take the low lane was caught by `cpu_aot_avx2_permutes`, so the run does detect a broken translator. On this branch, each of the eight mutations fails `cpu_aot_avx2_permutes`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability changed; the export count is updated.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:14 +00:00
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:30Z.


Verified 26fedf7 on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, dev preset. It merges cleanly with main at edc2e54. ctest --preset dev --no-tests=error -R "^cpu_" -j 4: 100% tests passed, 0 failed out of 119, and the new controls hold on an Intel host too.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084273031 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/668#issuecomment-7084273031). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T19:17:30Z. --- Verified `26fedf7` on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, `dev` preset. It merges cleanly with `main` at `edc2e54`. `ctest --preset dev --no-tests=error -R "^cpu_" -j 4`: 100% tests passed, 0 failed out of 119, and the new controls hold on an Intel host too. 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!662
No description provided.