fix(shader): accept neg on VOP3-encoded float compares #260

Merged
adriadam10 merged 2 commits from upstream-pr/260 into main 2026-10-02 19:22:19 +00:00
adriadam10 commented 2026-10-01 20:21:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-01T20:21:02Z.


What

neg on a VOP3-encoded float compare threw "VOP3 source modifiers are not implemented", e.g. v_cmp_lt_f32_e64 vcc_lo, -v14, v15 or v_cmpx_le_f32_e64 -v4, v5. Compares have a scalar destination, so checkNativeVop3Modifiers sends them through the carryInOut || scalarDst branch, which rejects neg (it is meant for the carry ops). abs already passed, and the VOPC branch of DecodeRdnaVop3 already applies both through applyNativeVop3SourceModifiers, so only the check was in the way. Float compares (isVopcFloatCompareOpcode) now accept neg there; integer compares and the carry ops still reject it.

Compilers emit these for things like -x < y or -|x| > y, so this throws on ordinary shaders.

Found while writing the VOPC test in #259.

Test agc_driver_vop3_compare_modifiers: wave32 shader (words from llvm-mc -mcpu=gfx1013) with 9 VOP3 compares using -x, -|x|: f32 and f16, VCC and SGPR destinations, two cmpx. One bit per lane each, checked against a C++ model. Inputs: NaN, ±inf, ±0, ±1, the smallest normal, f16 denormals, with flipped signs. f32 denormals are left out because the shader flushes them, which is not what this test is about.

Tested

Linux: passes on RADV (Radeon 660M) and lavapipe; without the fix it fails with "VOP3 source modifiers are not implemented". Full ctest (99) passes.

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: #251 (test harness); review only the last commit
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4709126356 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/260). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-01T20:21:02Z. --- ### What `neg` on a VOP3-encoded float compare threw "VOP3 source modifiers are not implemented", e.g. `v_cmp_lt_f32_e64 vcc_lo, -v14, v15` or `v_cmpx_le_f32_e64 -v4, v5`. Compares have a scalar destination, so `checkNativeVop3Modifiers` sends them through the `carryInOut || scalarDst` branch, which rejects `neg` (it is meant for the carry ops). `abs` already passed, and the VOPC branch of `DecodeRdnaVop3` already applies both through `applyNativeVop3SourceModifiers`, so only the check was in the way. Float compares (`isVopcFloatCompareOpcode`) now accept `neg` there; integer compares and the carry ops still reject it. Compilers emit these for things like `-x < y` or `-|x| > y`, so this throws on ordinary shaders. Found while writing the VOPC test in #259. Test `agc_driver_vop3_compare_modifiers`: wave32 shader (words from `llvm-mc -mcpu=gfx1013`) with 9 VOP3 compares using `-x`, `-|x|`: f32 and f16, VCC and SGPR destinations, two `cmpx`. One bit per lane each, checked against a C++ model. Inputs: NaN, ±inf, ±0, ±1, the smallest normal, f16 denormals, with flipped signs. f32 denormals are left out because the shader flushes them, which is not what this test is about. ### Tested Linux: passes on RADV (Radeon 660M) and lavapipe; without the fix it fails with "VOP3 source modifiers are not implemented". Full ctest (99) passes. ### Checklist - [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: #251 (test harness); review only the last commit - [x] AI-assisted: yes
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!260
No description provided.