fix(recompiler): accept SDWA destination selects on v_not_b32 #2200

Merged
XairRrR merged 1 commit from upstream-pr/2200 into main 2026-10-10 06:14:14 +00:00
XairRrR commented 2026-10-09 11:29:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:29:41Z.


What

Uncharted: Legacy of Thieves Collection (PPSA05684) stops on main with:

VOP1 SDWA destination selector 4 (unused 2, source selector 6) of opcode 0x37 at pc 0x98 is not supported

that is v_not_b32_sdwa ... dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE. v_not_b32_sdwa takes dst_sel and dst_unused like the other 32-bit VOP1 SDWA forms (RDNA2 ISA section 6.3.1 "SDWA"; LLVM VOP1Instructions.td gives V_NOT_B32 a VOP1_SDWA encoding with both operands). The rule now allows byte and word destinations with every unused mode, which the existing SDWA writeback implements. SdwaDestination checks WORD_0 with UNUSED_PRESERVE and fails without the fix.

Not checked on hardware.

Tested

Arch Linux, GCC 16.2.1, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.71.09).

  • The branch alone on current main (d70b8998): tools/check_conventions.py passes; of the 513 ctest tests all pass except agc_driver_dcc_keys_first_write, which fails the same way on main (an unchanged pending image was uploaded again). agc_driver_storage_cache_budget passes run alone; under ctest -j8 a local 3 GB RSS limit stopped it.
  • Uncharted: Legacy of Thieves Collection (PPSA05684): with this and the other changes of its bring-up, the title boots past the stop quoted above and reaches its main menu.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799797317 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2200). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-09T11:29:41Z. --- ### What Uncharted: Legacy of Thieves Collection (PPSA05684) stops on `main` with: ``` VOP1 SDWA destination selector 4 (unused 2, source selector 6) of opcode 0x37 at pc 0x98 is not supported ``` that is `v_not_b32_sdwa ... dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE`. `v_not_b32_sdwa` takes `dst_sel` and `dst_unused` like the other 32-bit VOP1 SDWA forms (RDNA2 ISA section 6.3.1 "SDWA"; LLVM `VOP1Instructions.td` gives `V_NOT_B32` a `VOP1_SDWA` encoding with both operands). The rule now allows byte and word destinations with every unused mode, which the existing SDWA writeback implements. `SdwaDestination` checks WORD_0 with UNUSED_PRESERVE and fails without the fix. Not checked on hardware. ### Tested Arch Linux, GCC 16.2.1, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.71.09). - The branch alone on current `main` (d70b8998): `tools/check_conventions.py` passes; of the 513 ctest tests all pass except `agc_driver_dcc_keys_first_write`, which fails the same way on `main` (`an unchanged pending image was uploaded again`). `agc_driver_storage_cache_budget` passes run alone; under `ctest -j8` a local 3 GB RSS limit stopped it. - Uncharted: Legacy of Thieves Collection (PPSA05684): with this and the other changes of its bring-up, the title boots past the stop quoted above and reaches its main menu. ### 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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
rmz-24 commented 2026-10-09 13:07:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T13:07:51Z.


Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. 09582357 cherry-picked onto current main d70b8998 (applies cleanly).

  • On this host agc_driver_dcc_keys_first_write passes on main and with this change, so the failure noted in the description (an unchanged pending image was uploaded again) doesn't reproduce on Windows/NVIDIA. agc_driver_storage_cache_budget also passes under ctest -j8 here (14 s).
  • Full ctest: 510/510.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081509089 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2200#issuecomment-6081509089). Originally posted by [rmz-24](https://github.com/rmz-24) on 2026-10-09T13:07:51Z. --- Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, full build plus `libs`. 09582357 cherry-picked onto current `main` d70b8998 (applies cleanly). - On this host `agc_driver_dcc_keys_first_write` passes on `main` and with this change, so the failure noted in the description (`an unchanged pending image was uploaded again`) doesn't reproduce on Windows/NVIDIA. `agc_driver_storage_cache_budget` also passes under `ctest -j8` here (14 s). - Full ctest: 510/510. AI-assisted: yes
fma-rc commented 2026-10-10 01:50:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T01:50:44Z.


Hardware measurement, and a run of the PR.

Radeon 610M (gfx1036), tools/hw-oracle, Linux 7.2.9, hsa-rocr 7.2.4, clang 23.1.1. Controls: ieee 0, dx10_clamp 1, denorm32 0, denorm16 3, round32 0, round16 0, fp16_overflow 0.

v_not_b32_sdwa with dst_sel BYTE_0–3, WORD_0, WORD_1 × dst_unused PAD, SEXT, PRESERVE × src0_sel BYTE_0–3, WORD_0, WORD_1, DWORD, each with and without sext: 252 forms. 24 rows each (8 sources × 3 previous destination values), wave32 and wave64: 12,096 results.

Every result equals: take the selected source field (sign-extended with sext), invert it, write its low bits into the destination field. PAD zeroes the other bits; SEXT fills the bits above the field with the field's top bit and zeroes those below; PRESERVE keeps the previous destination bits.

PR head 09582357 merged onto main ee501326, Release, GCC 16.2.1, on an RTX 5080 (615.71.09) and on RADV (Mesa 26.1.4, same Radeon 610M):

  • The SdwaDestination test passes on both.
  • The 252 forms, assembled and run through the recompiler on the same 24 rows, give the hardware values in all 6,048 results on both devices.
  • With RdnaVectorOpDecoder.cpp reverted to main, the test stops with VOP1 SDWA destination selector 4 (unused 2, source selector 6) of opcode 0x37 at pc 0xc0 is not supported.

Not measured: gfx1013.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092374784 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2200#issuecomment-6092374784). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-10T01:50:44Z. --- Hardware measurement, and a run of the PR. Radeon 610M (gfx1036), `tools/hw-oracle`, Linux 7.2.9, hsa-rocr 7.2.4, clang 23.1.1. Controls: ieee 0, dx10_clamp 1, denorm32 0, denorm16 3, round32 0, round16 0, fp16_overflow 0. `v_not_b32_sdwa` with dst_sel BYTE_0–3, WORD_0, WORD_1 × dst_unused PAD, SEXT, PRESERVE × src0_sel BYTE_0–3, WORD_0, WORD_1, DWORD, each with and without `sext`: 252 forms. 24 rows each (8 sources × 3 previous destination values), wave32 and wave64: 12,096 results. Every result equals: take the selected source field (sign-extended with `sext`), invert it, write its low bits into the destination field. PAD zeroes the other bits; SEXT fills the bits above the field with the field's top bit and zeroes those below; PRESERVE keeps the previous destination bits. PR head 09582357 merged onto `main` ee501326, Release, GCC 16.2.1, on an RTX 5080 (615.71.09) and on RADV (Mesa 26.1.4, same Radeon 610M): - The `SdwaDestination` test passes on both. - The 252 forms, assembled and run through the recompiler on the same 24 rows, give the hardware values in all 6,048 results on both devices. - With `RdnaVectorOpDecoder.cpp` reverted to `main`, the test stops with `VOP1 SDWA destination selector 4 (unused 2, source selector 6) of opcode 0x37 at pc 0xc0 is not supported`. Not measured: gfx1013. AI-assisted: yes.
adriadam10 commented 2026-10-10 06:14:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:14:11Z.


Checked on the HW oracle (gfx1035): v_not_b32_sdwa over every dst_sel × dst_unused × src0_sel × sext (294 forms, 64 rows each, previous destination varied) matches the existing SDWA writeback bit for bit; agc_driver_sdwa_destination fails without the decoder change; scoped build + ctest green; no conflicts with #2376/#1898. Matches @fma-rc's gfx1036 measurement and @rmz-24's Windows run. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094548306 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2200#issuecomment-6094548306). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:14:11Z. --- Checked on the HW oracle (gfx1035): `v_not_b32_sdwa` over every dst_sel × dst_unused × src0_sel × sext (294 forms, 64 rows each, previous destination varied) matches the existing SDWA writeback bit for bit; `agc_driver_sdwa_destination` fails without the decoder change; scoped build + ctest green; no conflicts with #2376/#1898. Matches @fma-rc's gfx1036 measurement and @rmz-24's Windows run. Merging.
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!2200
No description provided.