feat(shader): implement the missing non-f64 VOPC compares #259

Merged
adriadam10 merged 2 commits from upstream-pr/259 into main 2026-10-02 08:14:38 +00:00
adriadam10 commented 2026-10-01 20:17:45 +00:00 (Migrated from github.com)

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


What

50 VOPC opcodes threw "VOPC opcode is not implemented" (and the same in their VOP3 encodings):

  • f32: v_cmpx_f/o/u/tru_f32
  • i32/u32: v_cmpx_f/t_i32, v_cmpx_f/t_u32
  • i64/u64: every v_cmp_* / v_cmpx_* (f, lt, eq, le, gt, ne, ge, t) except the seven already there
  • f16: v_cmp_f/o/u/nge/nlg/ngt/nle/nlt/tru_f16, v_cmpx_f/lg/o/u/nge/nlg/nle/tru_f16

The IR only has SLessThan64/ULessThan64 for 64-bit ordering, so emitInteger64Order builds gt/le/ge by swapping the operands and/or negating. emitFloatOrderedCompare gets half and cmpx parameters (the two existing callers pass false, false). The 64-bit entries are not DPP-capable, like the existing ones.

Not included: f64 compares (with the rest of f64), v_cmp_class_f16 (converting to f32 turns f16 denormals into normals, so the class bits need a bit-level classifier: separate PR).

Found with an ISA sweep (every gfx1013 opcode from llvm-mc through DecodeRdnaInstruction + TranslateInstruction).

Test agc_driver_vopc_compare: generated wave32 shader (words from llvm-mc -mcpu=gfx1013): 54 compares, each turned into one bit per lane (v_cndmask of VCC, or v_mov under the EXEC a cmpx leaves, then EXEC restored), packed with v_lshl_or_b32. Inputs: f32/f16 NaN, ±inf, ±0, equal pairs, denormals; 64-bit values whose signed and unsigned order differ, equal pairs, high-word-only differences; plus pseudo-random. A C++ model checks every bit. Four of the compares use the VOP3 encoding (with abs).

Found while testing (not fixed here)

  1. VOP3-encoded compares reject neg ("VOP3 source modifiers are not implemented"), also for existing ones like v_cmp_lt_f32_e64 vcc_lo, -v14, v15: compares have a scalar destination, so checkNativeVop3Modifiers takes the carryInOut || scalarDst branch, which rejects neg. abs works.
  2. On RADV (subgroup 64), a 64-thread wave32 dispatch that saves exec_lo to an SGPR, runs a cmpx and restores it gives wrong results in the second wave (lanes 32-63); lavapipe is fine. So this test dispatches a single wave. I have not looked at the cause yet.

Tested

Linux: passes on RADV (Radeon 660M) and lavapipe; without the change it fails with "VOPC opcode is 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:4709090064 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/259). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-01T20:17:45Z. --- ### What 50 VOPC opcodes threw "VOPC opcode is not implemented" (and the same in their VOP3 encodings): - f32: `v_cmpx_f/o/u/tru_f32` - i32/u32: `v_cmpx_f/t_i32`, `v_cmpx_f/t_u32` - i64/u64: every `v_cmp_*` / `v_cmpx_*` (f, lt, eq, le, gt, ne, ge, t) except the seven already there - f16: `v_cmp_f/o/u/nge/nlg/ngt/nle/nlt/tru_f16`, `v_cmpx_f/lg/o/u/nge/nlg/nle/tru_f16` The IR only has `SLessThan64`/`ULessThan64` for 64-bit ordering, so `emitInteger64Order` builds gt/le/ge by swapping the operands and/or negating. `emitFloatOrderedCompare` gets `half` and `cmpx` parameters (the two existing callers pass `false, false`). The 64-bit entries are not DPP-capable, like the existing ones. Not included: f64 compares (with the rest of f64), `v_cmp_class_f16` (converting to f32 turns f16 denormals into normals, so the class bits need a bit-level classifier: separate PR). Found with an ISA sweep (every gfx1013 opcode from `llvm-mc` through `DecodeRdnaInstruction` + `TranslateInstruction`). Test `agc_driver_vopc_compare`: generated wave32 shader (words from `llvm-mc -mcpu=gfx1013`): 54 compares, each turned into one bit per lane (`v_cndmask` of VCC, or `v_mov` under the EXEC a `cmpx` leaves, then EXEC restored), packed with `v_lshl_or_b32`. Inputs: f32/f16 NaN, ±inf, ±0, equal pairs, denormals; 64-bit values whose signed and unsigned order differ, equal pairs, high-word-only differences; plus pseudo-random. A C++ model checks every bit. Four of the compares use the VOP3 encoding (with `abs`). ### Found while testing (not fixed here) 1. VOP3-encoded compares reject `neg` ("VOP3 source modifiers are not implemented"), also for existing ones like `v_cmp_lt_f32_e64 vcc_lo, -v14, v15`: compares have a scalar destination, so `checkNativeVop3Modifiers` takes the `carryInOut || scalarDst` branch, which rejects `neg`. `abs` works. 2. On RADV (subgroup 64), a 64-thread wave32 dispatch that saves `exec_lo` to an SGPR, runs a `cmpx` and restores it gives wrong results in the second wave (lanes 32-63); lavapipe is fine. So this test dispatches a single wave. I have not looked at the cause yet. ### Tested Linux: passes on RADV (Radeon 660M) and lavapipe; without the change it fails with "VOPC opcode is 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
github-actions[bot] commented 2026-10-01 20:18:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-01T20:18:07Z.


Progress report (709d7fe → b637673)

📈 GPU shader instructions: 56.95% (+4.29%, +50 implemented instructions)

✅ 50 implemented
Encoding Name
VOPC V_CMPX_EQ_I64
VOPC V_CMPX_EQ_U64
VOPC V_CMPX_F_F16
VOPC V_CMPX_F_F32
VOPC V_CMPX_F_I32
VOPC V_CMPX_F_I64
VOPC V_CMPX_F_U32
VOPC V_CMPX_F_U64
VOPC V_CMPX_GE_I64
VOPC V_CMPX_GE_U64
VOPC V_CMPX_GT_I64
VOPC V_CMPX_GT_U64
VOPC V_CMPX_LE_I64
VOPC V_CMPX_LE_U64
VOPC V_CMPX_LG_F16
VOPC V_CMPX_LT_I64
VOPC V_CMPX_LT_U64
VOPC V_CMPX_NGE_F16
VOPC V_CMPX_NLE_F16
VOPC V_CMPX_NLG_F16
VOPC V_CMPX_O_F16
VOPC V_CMPX_O_F32
VOPC V_CMPX_TRU_F16
VOPC V_CMPX_TRU_F32
VOPC V_CMPX_T_I32
VOPC V_CMPX_T_I64
VOPC V_CMPX_T_U32
VOPC V_CMPX_T_U64
VOPC V_CMPX_U_F16
VOPC V_CMPX_U_F32
VOPC V_CMP_F_F16
VOPC V_CMP_F_I64
VOPC V_CMP_F_U64
VOPC V_CMP_GE_I64
VOPC V_CMP_GE_U64
VOPC V_CMP_GT_I64
VOPC V_CMP_LE_I64
VOPC V_CMP_LE_U64
VOPC V_CMP_LT_I64
VOPC V_CMP_NE_I64
VOPC V_CMP_NGE_F16
VOPC V_CMP_NGT_F16
VOPC V_CMP_NLE_F16
VOPC V_CMP_NLG_F16
VOPC V_CMP_NLT_F16
VOPC V_CMP_O_F16
VOPC V_CMP_TRU_F16
VOPC V_CMP_T_I64
VOPC V_CMP_T_U64
VOPC V_CMP_U_F16
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5939768070 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/259#issuecomment-5939768070). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-01T20:18:07Z. --- <!-- progress-report --> ### Progress report (709d7fe → b637673) 📈 **GPU shader instructions**: 56.95% (+4.29%, +50 implemented instructions) <details> <summary>✅ 50 implemented</summary> | Encoding | Name | | - | - | | VOPC | `V_CMPX_EQ_I64` | | VOPC | `V_CMPX_EQ_U64` | | VOPC | `V_CMPX_F_F16` | | VOPC | `V_CMPX_F_F32` | | VOPC | `V_CMPX_F_I32` | | VOPC | `V_CMPX_F_I64` | | VOPC | `V_CMPX_F_U32` | | VOPC | `V_CMPX_F_U64` | | VOPC | `V_CMPX_GE_I64` | | VOPC | `V_CMPX_GE_U64` | | VOPC | `V_CMPX_GT_I64` | | VOPC | `V_CMPX_GT_U64` | | VOPC | `V_CMPX_LE_I64` | | VOPC | `V_CMPX_LE_U64` | | VOPC | `V_CMPX_LG_F16` | | VOPC | `V_CMPX_LT_I64` | | VOPC | `V_CMPX_LT_U64` | | VOPC | `V_CMPX_NGE_F16` | | VOPC | `V_CMPX_NLE_F16` | | VOPC | `V_CMPX_NLG_F16` | | VOPC | `V_CMPX_O_F16` | | VOPC | `V_CMPX_O_F32` | | VOPC | `V_CMPX_TRU_F16` | | VOPC | `V_CMPX_TRU_F32` | | VOPC | `V_CMPX_T_I32` | | VOPC | `V_CMPX_T_I64` | | VOPC | `V_CMPX_T_U32` | | VOPC | `V_CMPX_T_U64` | | VOPC | `V_CMPX_U_F16` | | VOPC | `V_CMPX_U_F32` | | VOPC | `V_CMP_F_F16` | | VOPC | `V_CMP_F_I64` | | VOPC | `V_CMP_F_U64` | | VOPC | `V_CMP_GE_I64` | | VOPC | `V_CMP_GE_U64` | | VOPC | `V_CMP_GT_I64` | | VOPC | `V_CMP_LE_I64` | | VOPC | `V_CMP_LE_U64` | | VOPC | `V_CMP_LT_I64` | | VOPC | `V_CMP_NE_I64` | | VOPC | `V_CMP_NGE_F16` | | VOPC | `V_CMP_NGT_F16` | | VOPC | `V_CMP_NLE_F16` | | VOPC | `V_CMP_NLG_F16` | | VOPC | `V_CMP_NLT_F16` | | VOPC | `V_CMP_O_F16` | | VOPC | `V_CMP_TRU_F16` | | VOPC | `V_CMP_T_I64` | | VOPC | `V_CMP_T_U64` | | VOPC | `V_CMP_U_F16` | </details>
github-actions[bot] commented 2026-10-01 20:22:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-01T20:22:02Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#309 core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp L452-453
core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp L321, L1161-1162
core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp L120
core/shader/recompiler/Translation/src/CompareInstructions.cpp L57-59, L64
#310 core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp L452-453
core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp L321, L1161-1162
core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp L119-121
core/shader/recompiler/Translation/src/VectorInstructions.cpp L147
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5939838600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/259#issuecomment-5939838600). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-01T20:22:02Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #309 | `core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp` [L452-453](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp#L452-L453)<br>`core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp` [L321](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L321), [L1161-1162](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L1161-L1162)<br>`core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp` [L120](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp#L120)<br>`core/shader/recompiler/Translation/src/CompareInstructions.cpp` [L57-59](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/Translation/src/CompareInstructions.cpp#L57-L59), [L64](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/Translation/src/CompareInstructions.cpp#L64) | | | | #310 | `core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp` [L452-453](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp#L452-L453)<br>`core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp` [L321](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L321), [L1161-1162](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cpp#L1161-L1162)<br>`core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp` [L119-121](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp#L119-L121)<br>`core/shader/recompiler/Translation/src/VectorInstructions.cpp` [L147](https://github.com/boykopovar/AnyPS5/blob/8ed9e7ab5e07117e113ed8a9c818386c35f652d5/core/shader/recompiler/Translation/src/VectorInstructions.cpp#L147) | | |
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!259
No description provided.