feat(shader): VOP3 v_add/sub_nc_i32 (clamp), v_mul_lo_u16, 16-bit mads, v_ashrrev_i64 #257
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/257"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-01T20:09:25Z.
What
These VOP3 opcodes threw "VOP3 opcode is not implemented":
v_add_nc_i32,v_sub_nc_i32(0x37f, 0x376), including clamp: these are what compilers emit for signed saturating add/sub (sadd.sat/ssub.sat), so clamp saturates to[INT32_MIN, INT32_MAX](overflow from the sign bits, result(a >> 31) ^ 0x7fffffff). Other modifiers stay rejected.v_mul_lo_u16(0x305):integer16Binary(IMul32), op_sel on sources like the other 16-bit binaries.v_mad_u16,v_mad_i16(0x340, 0x35e): 16-bit result, op_sel on all three sources and the destination half.v_mad_u32_u16,v_mad_i32_i16(0x373, 0x375): 16x16 product plus a 32-bit addend, 32-bit result. They share the I16 ternary decode path butapplyNativeVop3I16TernarySelectorsno longer sets the 16-bit destination select or src2 op_sel for them (with it the result was truncated to 16 bits; the test caught that).v_ashrrev_i64(0x301): next to the existingv_lshrrev_b64.Found with an ISA sweep (every gfx1013 opcode from
llvm-mcthroughDecodeRdnaInstruction+TranslateInstruction).Test
agc_driver_vop3_integer: hand-assembled compute shader (words fromllvm-mc -mcpu=gfx1013), 64 lanes with edge inputs (INT32_MIN/MAX overflow pairs, -1, 0x8000 halves, shift counts 0/31/32/63/64) and pseudo-random ones, 14 results per lane checked against a C++ model, including the clamp and op_sel forms. 16-bit results are checked on the written half only. No cross-lane ops, so it runs on lavapipe in CI.Tested
Linux: passes on RADV (Radeon 660M) and lavapipe; without the change it fails with "VOP3 opcode is not implemented". Full ctest (99) passes.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-01T20:09:49Z.
Progress report (
709d7fe→e144f43)📈 GPU shader instructions: 53.34% (+0.68%, +8 implemented instructions)
✅ 8 implemented
V_ADD_NC_I32V_ASHRREV_I64V_MAD_I16V_MAD_I32_I16V_MAD_U16V_MAD_U32_U16V_MUL_LO_U16V_SUB_NC_I32