Commit Graph

6 Commits

Author SHA1 Message Date
edb22940c6 chore(shader): merge upstream main into unary binary64 literal handling
Keep the targeted regression and the intervening upstream changes together for review.
2026-11-22 23:02:05 +01:00
53ce204ee6 fix(shader): decode literal words for unary binary64 operations
GFX10 places the separate literal dword above 32 zero bits for a binary64 source. Use the same source interpretation for reciprocal, square root and exponent decomposition so literal and register-pair forms produce the same color.
2026-11-22 19:32:46 +01:00
3e384c2c86 fix(shader): place f64 literal words in the upper half
RDNA2 reads the literal dword of a double as its high word. Preserve LLVM's distinction between a printed literal and an inline integer so conversions and adds receive the encoded value.
2026-11-22 16:48:29 +01:00
1062df5154 Shader: accept abs on v_pack_b32_f16 (a sign clear of the packed half)
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
2026-11-22 15:23:17 +02:00
32e052c569 Shader: accept neg on v_pack_b32_f16, a sign flip of the packed half
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>
2026-11-22 06:18:55 -06:00
b7905794d0 shader_ir: preserve VOP3 FP abs/neg modifiers on constant operands
Keep VOP3 FP source modifiers (neg(...), |...|, -|...|, abs(...), and nested combinations) as abs/neg flags on imm and fimm operands instead of applying two's-complement integer negation or folding outer '-' before FAbs, matching LLVM AMDGPUInstPrinter::printOperandAndFPInputMods.

Plain signed numeric literals (-1, -1.0, 0x10) keep their existing dict layout. Also handle -0x... inside modifiers, preserve abs on sext(...), and apply abs then neg in tools/shader_meta.py::_imm_u32.

Verified on CPU with tests/test_shader_ir.py, tests/test_shader_meta.py, tests/test_cpu_ref.py, tools/f32_fuzz.py and the full tests/semantic suite (1,027 tests).
2026-11-22 01:09:48 -04:00