Follow-up to #1570, which took the `neg` half of SHADER-260 and left `abs`
refused. `abs` is the ISA's absolute value of the operand: a clear of the
sign bit, on the 16-bit half the operand contributes and applied before
`neg` (which #1570 emits as a bit 15 flip). The instruction already moved
each half unchanged, so the translator emitted nothing for `abs` and threw
`Unsupported("v_pack_b32_f16 abs modifier")` for any shader that used it.
Emit the clear instead: OpBitwiseAnd 0x7FFF on the selected half, before
the `neg` xor. No hardware run of this instruction with `abs` exists, so
the docs row says the rule is ISA-derived and unmeasured rather than
quoting a measurement.
Tests: exact-bit CPU cases in tests/semantic/test_pack_b32_f16_mods.py and
tests/test_values.py (both halves, op_sel, an sNaN payload, neg+abs order),
the interpreter-run GPU fixture ps_f16_pack_mods with its words derived
from the rule, and the row in docs/design.md.
SHADER-260, Depends on: #1570
SHADER-260 measured on gfx1036 that a VOP3 `neg` on this instruction is a
plain sign flip of the 16-bit half that operand contributes, before any
quieting (0x7c01 -> 0xfc01 under IEEE mode 0 and -> 0xfe01 under mode 1), in
either half and with op_sel. The translator refused every modifier, so any
shader using it failed to translate. `abs` stays refused because its rule on
this instruction is unmeasured, and the mode-1 signalling-NaN quieting is left
out until SHADER-190 settles which mode the game's shaders run in.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
tests/spirv_interp.py runs the straight-line, single-lane SPIR-V the translator
emits for branch-free shaders (binary32 rounding after every op, GLSL.std.450
subset, Function/Output variables). Unknown opcodes raise NotImplementedError.
- test_values.py: 49 value checks over the supported instruction families, with
references written in plain Python from the ISA definitions.
- test_f16_op_sel_values.py: 84 value checks for op_sel on f16 VOP3 ops (all
select combinations, neg/abs/clamp, fmac).
- listing.py: hand-written listing helper. shader_ir.parse_file treats the first
line of a listing as its header, so the helper writes one; test_f16_op_sel.py
used to lose its first instruction and now uses the helper.
None of these need llvm-mc or spirv-tools. Mutation-checked: breaking the
op_sel source index or the destination merge makes them fail.