feat(relinker): lower the remaining AVX2 instructions under --to-avx #23636

Open
pwnAtl4nt1s wants to merge 8 commits from upstream-pr/23636 into main
pwnAtl4nt1s commented 2026-11-19 11:20:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pwnAtl4nt1s on 2026-11-19T11:20:55Z.


What

--to-avx now lowers every remaining AVX2 instruction, so a converted title no longer stops with an illegal instruction on an AVX-only host (Sandy Bridge, Ivy Bridge) because of AVX2:

  • 256-bit VPMOVMSKB: VEX.128 VPMOVMSKB on each half, masks combined through a stack slot below the red zone (no RFLAGS write).
  • VPMASKMOVD/VPMASKMOVQ rewritten in place to VMASKMOVPS/VMASKMOVPD (same masking and fault suppression per the SDM); 256-bit VMOVNTDQA rewritten to VMOVDQA (same alignment fault, no non-temporal hint).
  • 256-bit VMPSADBW (high half takes imm[5:3]) and VPBLENDVB (mask register split too) added to the lane-split lowering.
  • VPSLLVD/Q, VPSRLVD/Q, VPSRAVD (128 and 256-bit): per element, the count zero-extended into a low quadword drives the uniform VPSLL/VPSRL/VPSRA shift, then VBLENDPS/VBLENDPD keeps that element; counts above the element width give the SDM result.
  • All eight gathers: per element without branches; the address is built in a saved GPR (VPEXTRD+MOVSXD or VPEXTRQ, then LEA) and read with a one-element VMASKMOVPS/VMASKMOVPD, so masked-off elements touch no memory; VBLENDVPS/VBLENDVPD merges and the mask is cleared. The fault-delivery difference from the SDM (restart instead of partial progress) is recorded in the debt fragment.
  • The GPR+YMM execution harness of the VPMOVMSKB test moved to codegen/tests/GprVectorExecution.hpp and is shared with the gather test.
  • Debt fragment docs/dev/debt/changes/feat-relinker-avx-avx2-gaps.md and docs/user/USAGE.md updated.

Semantics are from the Intel SDM vol. 2 entries of each instruction.

Tested

Linux x86-64 (Ubuntu 24.04, GCC 13.3), relinker-only build: ctest 1014/1014 passed. The new and extended tests compare every lowering with the SDM result and, since the host has AVX2, with the original instruction executed on the host, for every destination/source register (aliasing included), RFLAGS, the other GPRs and YMM registers and the red zone; memory operands at a page end, and masked-off gather/masked-load elements on a guard page. Mutation checks (deliberately broken lowerings) are caught by the tests. Not tested on an AVX-only CPU, nor with a title.

tools/pr_overlap.py could not be run from this environment (no GraphQL access); I checked main and found no lowering of these instructions.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5393909953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636). Originally posted by [pwnAtl4nt1s](https://github.com/pwnAtl4nt1s) on 2026-11-19T11:20:55Z. --- ### What `--to-avx` now lowers every remaining AVX2 instruction, so a converted title no longer stops with an illegal instruction on an AVX-only host (Sandy Bridge, Ivy Bridge) because of AVX2: - 256-bit VPMOVMSKB: VEX.128 VPMOVMSKB on each half, masks combined through a stack slot below the red zone (no RFLAGS write). - VPMASKMOVD/VPMASKMOVQ rewritten in place to VMASKMOVPS/VMASKMOVPD (same masking and fault suppression per the SDM); 256-bit VMOVNTDQA rewritten to VMOVDQA (same alignment fault, no non-temporal hint). - 256-bit VMPSADBW (high half takes imm[5:3]) and VPBLENDVB (mask register split too) added to the lane-split lowering. - VPSLLVD/Q, VPSRLVD/Q, VPSRAVD (128 and 256-bit): per element, the count zero-extended into a low quadword drives the uniform VPSLL/VPSRL/VPSRA shift, then VBLENDPS/VBLENDPD keeps that element; counts above the element width give the SDM result. - All eight gathers: per element without branches; the address is built in a saved GPR (VPEXTRD+MOVSXD or VPEXTRQ, then LEA) and read with a one-element VMASKMOVPS/VMASKMOVPD, so masked-off elements touch no memory; VBLENDVPS/VBLENDVPD merges and the mask is cleared. The fault-delivery difference from the SDM (restart instead of partial progress) is recorded in the debt fragment. - The GPR+YMM execution harness of the VPMOVMSKB test moved to `codegen/tests/GprVectorExecution.hpp` and is shared with the gather test. - Debt fragment `docs/dev/debt/changes/feat-relinker-avx-avx2-gaps.md` and `docs/user/USAGE.md` updated. Semantics are from the Intel SDM vol. 2 entries of each instruction. ### Tested Linux x86-64 (Ubuntu 24.04, GCC 13.3), relinker-only build: `ctest` 1014/1014 passed. The new and extended tests compare every lowering with the SDM result and, since the host has AVX2, with the original instruction executed on the host, for every destination/source register (aliasing included), RFLAGS, the other GPRs and YMM registers and the red zone; memory operands at a page end, and masked-off gather/masked-load elements on a guard page. Mutation checks (deliberately broken lowerings) are caught by the tests. Not tested on an AVX-only CPU, nor with a title. `tools/pr_overlap.py` could not be run from this environment (no GraphQL access); I checked `main` and found no lowering of these instructions. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-19 11:23:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T11:23:47Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 005e682509:

  • Conventions: tools/check_conventions.py failed.
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md)
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: No notes, investigation `.md` files or images added to the repository (attach them to this PR)
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: New third-party code is a submodule built from source
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: Generic behaviour, not specific to one title
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: Depends on:
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: Fixes:
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: Unblocks:
    (pull request): error: [pr-template] Fill in the pull request template: unchecked: GPUs tested:
    (pull request): error: [pr-template] Fill in the pull request template: answer AI-assisted with yes or no
    (pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none
    14 findings, 14 errors; GitHub shows at most 10 error annotations, the job summary lists all
    
  • Build: avx2_twin_lowering_tests, gather_lowering_tests, lane_split_lowering_tests, move_mask_lowering_tests, variable_shift_lowering_tests built cleanly.
  • CTest (avx2_twin_lowering, lane_split_lowering, move_mask_lowering, variable_shift_lowering, gather_lowering):
    1/5 Test #5964: avx2_twin_lowering ...............   Passed    0.02 sec
    2/5 Test #5968: move_mask_lowering ...............   Passed    0.08 sec
    3/5 Test #5965: lane_split_lowering ..............   Passed    0.10 sec
    4/5 Test #5969: variable_shift_lowering ..........   Passed    0.04 sec
    5/5 Test #5970: gather_lowering ..................   Passed    0.05 sec
    100% tests passed, 0 tests failed out of 5
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5974088034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636#pullrequestreview-5974088034). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T11:23:47Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `005e682509`: - **Conventions**: `tools/check_conventions.py` failed. ``` (pull request): error: [pr-template] Fill in the pull request template: unchecked: No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) (pull request): error: [pr-template] Fill in the pull request template: unchecked: Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file (pull request): error: [pr-template] Fill in the pull request template: unchecked: No notes, investigation `.md` files or images added to the repository (attach them to this PR) (pull request): error: [pr-template] Fill in the pull request template: unchecked: New third-party code is a submodule built from source (pull request): error: [pr-template] Fill in the pull request template: unchecked: Generic behaviour, not specific to one title (pull request): error: [pr-template] Fill in the pull request template: unchecked: Depends on: (pull request): error: [pr-template] Fill in the pull request template: unchecked: Fixes: (pull request): error: [pr-template] Fill in the pull request template: unchecked: Unblocks: (pull request): error: [pr-template] Fill in the pull request template: unchecked: GPUs tested: (pull request): error: [pr-template] Fill in the pull request template: answer AI-assisted with yes or no (pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none 14 findings, 14 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` - **Build**: `avx2_twin_lowering_tests`, `gather_lowering_tests`, `lane_split_lowering_tests`, `move_mask_lowering_tests`, `variable_shift_lowering_tests` built cleanly. - **CTest** (`avx2_twin_lowering`, `lane_split_lowering`, `move_mask_lowering`, `variable_shift_lowering`, `gather_lowering`): ``` 1/5 Test #5964: avx2_twin_lowering ............... Passed 0.02 sec 2/5 Test #5968: move_mask_lowering ............... Passed 0.08 sec 3/5 Test #5965: lane_split_lowering .............. Passed 0.10 sec 4/5 Test #5969: variable_shift_lowering .......... Passed 0.04 sec 5/5 Test #5970: gather_lowering .................. Passed 0.05 sec 100% tests passed, 0 tests failed out of 5 ``` Requesting changes for the points above.
MarcZX10 commented 2026-11-21 07:48:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:48:50Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the gather lowering’s incorrect handling of no-base and RIP-relative addresses.

What I ran

Reviewed head 005e68250983386a1821ac868997e0c9519eb1fb using the prepared diff and pinned repo_read.py reader. No build or tests were run in this review; the test result in the description is author-reported.

Results

Check Result Note
Changed code review failed Gather address generation drops address components
Build and tests not run Author reports 1014 tests passed

Findings

Blocking

  • core/relinker/codegen/src/x86/GatherLowering.cpp:47: Gather address generation does not preserve all valid memory addressing forms. For SIB mod=0, base=5 (no base), _address emits [address + index*scale + displacement], treating the gather index as an additional address index; the original effective address is absolute displacement plus the vector index times scale. For RIP-relative operands, it similarly uses a GPR with the displacement and omits RIP-relative relocation, yielding an incorrect address in the stub. This can make valid gathers load from the wrong location. Preserve these address forms when building each element address, or reject forms that cannot be represented correctly.

Non-blocking

None.

Sources

  • Prepared diff and pinned source at the reviewed head: core/relinker/codegen/src/x86/GatherLowering.cpp, core/relinker/codegen/include/codegen/x86/VexEncoding.hpp, and core/relinker/codegen/src/x86/StubBodyBuilder.cpp.

Not verified

  • Build and test execution were not performed. The 1014/1014 result and execution-test coverage are author-reported.
  • All added lines in the changed files were read. No changed files were excluded by the prepared review bundle.

To get this to a good state

  • Correct or explicitly reject gather address forms that the lowering cannot faithfully reconstruct, then rerun the relinker build and test suite, including no-base and RIP-relative gather cases.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003949558 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636#pullrequestreview-6003949558). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:48:50Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the gather lowering’s incorrect handling of no-base and RIP-relative addresses. ## What I ran Reviewed head `005e68250983386a1821ac868997e0c9519eb1fb` using the prepared diff and pinned `repo_read.py` reader. No build or tests were run in this review; the test result in the description is author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Gather address generation drops address components | | Build and tests | not run | Author reports 1014 tests passed | ## Findings ### Blocking - `core/relinker/codegen/src/x86/GatherLowering.cpp:47`: Gather address generation does not preserve all valid memory addressing forms. For SIB `mod=0, base=5` (no base), `_address` emits `[address + index*scale + displacement]`, treating the gather index as an additional address index; the original effective address is absolute displacement plus the vector index times scale. For RIP-relative operands, it similarly uses a GPR with the displacement and omits RIP-relative relocation, yielding an incorrect address in the stub. This can make valid gathers load from the wrong location. Preserve these address forms when building each element address, or reject forms that cannot be represented correctly. ### Non-blocking None. ## Sources - Prepared diff and pinned source at the reviewed head: `core/relinker/codegen/src/x86/GatherLowering.cpp`, `core/relinker/codegen/include/codegen/x86/VexEncoding.hpp`, and `core/relinker/codegen/src/x86/StubBodyBuilder.cpp`. ## Not verified - Build and test execution were not performed. The 1014/1014 result and execution-test coverage are author-reported. - All added lines in the changed files were read. No changed files were excluded by the prepared review bundle. ## To get this to a good state - Correct or explicitly reject gather address forms that the lowering cannot faithfully reconstruct, then rerun the relinker build and test suite, including no-base and RIP-relative gather cases.
PrivacyOnion commented 2026-11-21 09:08:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T09:08:18Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2b71fe7367:

  • Conventions: tools/check_conventions.py passed.
  • Build: avx2_twin_lowering_tests, gather_lowering_tests, lane_split_lowering_tests, move_mask_lowering_tests, variable_shift_lowering_tests built cleanly.
  • CTest (avx2_twin_lowering, lane_split_lowering, move_mask_lowering, variable_shift_lowering, gather_lowering):
    1/5 Test #6211: avx2_twin_lowering ...............   Passed    0.01 sec
    2/5 Test #6215: move_mask_lowering ...............   Passed    0.02 sec
    3/5 Test #6216: variable_shift_lowering ..........   Passed    0.02 sec
    4/5 Test #6212: lane_split_lowering ..............   Passed    0.06 sec
    5/5 Test #6217: gather_lowering ..................   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 5
    
  • Negative control: with core/relinker/codegen/include/codegen/x86/LaneSplitLowering.hpp, core/relinker/codegen/src/x86/Amd64OnlyInstructionMatcher.cpp, core/relinker/codegen/src/x86/Avx2TwinLowering.cpp, core/relinker/codegen/src/x86/LaneSplitLowering.cpp, core/relinker/codegen/src/x86/GatherLowering.cpp, core/relinker/codegen/src/x86/MoveMaskLowering.cpp, core/relinker/codegen/src/x86/VariableShiftLowering.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified gather address generation in _address (core/relinker/codegen/src/x86/GatherLowering.cpp:38) handles base-relative and no-base (mod=0, base=5) VSIB encodings with LEA index scaling and 32-bit displacement without dropping components.
    • Verified 256-bit VPMOVMSKB lowering in MoveMaskLowering.cpp correctly uses 16-bit stack stores, zero-extends via 32-bit MOV into the destination GPR, preserves RFLAGS, and respects red zone safety.
    • Verified variable shift lowerings in VariableShiftLowering.cpp zero-extend per-element counts via VPMOVZXDQ to match Intel SDM saturation and out-of-range shift semantics.
    • Verified lane-split handling in LaneSplitLowering.cpp for VMPSADBW (splitting immediate bits 2:0 and 5:3) and VPBLENDVB (correctly extracting and splitting the IS4 mask register).
    • Verified in-place opcode/map rewrites in Avx2TwinLowering.cpp for VPMASKMOVD, VPMASKMOVQ, and 256-bit VMOVNTDQA to valid AVX equivalents.
    • Verified all AGENTS.md rules, conventional commits, debt fragment docs/dev/debt/changes/feat-relinker-avx-avx2-gaps.md, and mechanical gate passes.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004310684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636#pullrequestreview-6004310684). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T09:08:18Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `2b71fe7367`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `avx2_twin_lowering_tests`, `gather_lowering_tests`, `lane_split_lowering_tests`, `move_mask_lowering_tests`, `variable_shift_lowering_tests` built cleanly. - **CTest** (`avx2_twin_lowering`, `lane_split_lowering`, `move_mask_lowering`, `variable_shift_lowering`, `gather_lowering`): ``` 1/5 Test #6211: avx2_twin_lowering ............... Passed 0.01 sec 2/5 Test #6215: move_mask_lowering ............... Passed 0.02 sec 3/5 Test #6216: variable_shift_lowering .......... Passed 0.02 sec 4/5 Test #6212: lane_split_lowering .............. Passed 0.06 sec 5/5 Test #6217: gather_lowering .................. Passed 0.02 sec 100% tests passed, 0 tests failed out of 5 ``` - **Negative control**: with `core/relinker/codegen/include/codegen/x86/LaneSplitLowering.hpp`, `core/relinker/codegen/src/x86/Amd64OnlyInstructionMatcher.cpp`, `core/relinker/codegen/src/x86/Avx2TwinLowering.cpp`, `core/relinker/codegen/src/x86/LaneSplitLowering.cpp`, `core/relinker/codegen/src/x86/GatherLowering.cpp`, `core/relinker/codegen/src/x86/MoveMaskLowering.cpp`, `core/relinker/codegen/src/x86/VariableShiftLowering.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified gather address generation in _address (core/relinker/codegen/src/x86/GatherLowering.cpp:38) handles base-relative and no-base (mod=0, base=5) VSIB encodings with LEA index scaling and 32-bit displacement without dropping components. - Verified 256-bit VPMOVMSKB lowering in MoveMaskLowering.cpp correctly uses 16-bit stack stores, zero-extends via 32-bit MOV into the destination GPR, preserves RFLAGS, and respects red zone safety. - Verified variable shift lowerings in VariableShiftLowering.cpp zero-extend per-element counts via VPMOVZXDQ to match Intel SDM saturation and out-of-range shift semantics. - Verified lane-split handling in LaneSplitLowering.cpp for VMPSADBW (splitting immediate bits 2:0 and 5:3) and VPBLENDVB (correctly extracting and splitting the IS4 mask register). - Verified in-place opcode/map rewrites in Avx2TwinLowering.cpp for VPMASKMOVD, VPMASKMOVQ, and 256-bit VMOVNTDQA to valid AVX equivalents. - Verified all AGENTS.md rules, conventional commits, debt fragment docs/dev/debt/changes/feat-relinker-avx-avx2-gaps.md, and mechanical gate passes. Looks Good To Me
MarcZX10 commented 2026-11-21 09:22:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T09:22:26Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: keep the gather address temporary distinct from the destination, mask, and index registers so the lowering preserves its inputs.

What I ran

Reviewed head 2b71fe7367ebf3281217dd0aee60a42c4a06e676. I read the prepared description, commits, manifest, diff, and targeted source and test files. I did not run commands or tests.

Results

Check Result Note
Source review failed Gather lowering overwrites live registers
Tests not run No local test run

Findings

Blocking

  • core/relinker/codegen/src/x86/GatherLowering.cpp:121-127: The address register is chosen from a fixed candidate list while excluding only the memory base. It can alias the gather destination, mask, or index. For example, when destination is ymm0, mask is ymm1, index is ymm2, and base is r3, the first candidate r0 is selected as the address temporary. _address then overwrites r0 before the final merge, so the original destination is lost; if the chosen register aliases the index or mask, those inputs are also lost. Select a temporary that avoids every live operand, or preserve and restore any aliased operand before using it.

Non-blocking

None.

Not verified

I did not run the reported test suite, build, or a title on hardware. The prepared diff and manifest were read; targeted full source reads covered the gather, variable shift, move mask, lane split, AVX2 twin, matcher, and gather tests. The remaining changed files were not read in full, although their diff hunks and manifest entries were inspected. No excluded-file list was available in the review folder.

To get this to a good state

Choose a gather address temporary that cannot clobber the destination, mask, or index operands, and rerun the gather lowering tests and reported test suite.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004360179 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636#pullrequestreview-6004360179). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T09:22:26Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: keep the gather address temporary distinct from the destination, mask, and index registers so the lowering preserves its inputs. ## What I ran Reviewed head `2b71fe7367ebf3281217dd0aee60a42c4a06e676`. I read the prepared description, commits, manifest, diff, and targeted source and test files. I did not run commands or tests. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Gather lowering overwrites live registers | | Tests | not run | No local test run | ## Findings ### Blocking - `core/relinker/codegen/src/x86/GatherLowering.cpp:121-127`: The address register is chosen from a fixed candidate list while excluding only the memory base. It can alias the gather destination, mask, or index. For example, when destination is `ymm0`, mask is `ymm1`, index is `ymm2`, and base is `r3`, the first candidate `r0` is selected as the address temporary. `_address` then overwrites `r0` before the final merge, so the original destination is lost; if the chosen register aliases the index or mask, those inputs are also lost. Select a temporary that avoids every live operand, or preserve and restore any aliased operand before using it. ### Non-blocking None. ## Not verified I did not run the reported test suite, build, or a title on hardware. The prepared diff and manifest were read; targeted full source reads covered the gather, variable shift, move mask, lane split, AVX2 twin, matcher, and gather tests. The remaining changed files were not read in full, although their diff hunks and manifest entries were inspected. No excluded-file list was available in the review folder. ## To get this to a good state Choose a gather address temporary that cannot clobber the destination, mask, or index operands, and rerun the gather lowering tests and reported test suite.
ligmaSec commented 2026-12-03 11:55:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:55:16Z.

Review: COMMENTED


Built this head with ANYPS5_RELINKER_ONLY=ON using GCC 14.2 on Linux x86-64. The lane split, move mask, and variable shift suites passed. gather_lowering segfaulted on the first run and all three reruns. The same fixture passed after changing only its CPU feature probe in the scratch build.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169251890 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23636#pullrequestreview-6169251890). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T11:55:16Z. **Review:** COMMENTED --- Built this head with `ANYPS5_RELINKER_ONLY=ON` using GCC 14.2 on Linux x86-64. The lane split, move mask, and variable shift suites passed. `gather_lowering` segfaulted on the first run and all three reruns. The same fixture passed after changing only its CPU feature probe in the scratch build. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/23636:upstream-pr/23636'
git switch 'upstream-pr/23636'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/23636'
git switch 'upstream-pr/23636'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/23636'
git switch 'upstream-pr/23636'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/23636'
git switch 'main'
git merge --squash 'upstream-pr/23636'
git switch 'main'
git merge --ff-only 'upstream-pr/23636'
git switch 'main'
git merge 'upstream-pr/23636'
git push origin 'main'
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
boykopovar/AnyPS5!23636
No description provided.