A literal source is one ISA dword (bits 63:32 of the constant) only when its
printed spelling fits one dword. LLVM pads nothing, so such a literal prints in
at most 8 hex digits; a 16-digit spelling is the whole binary64 value. The
magnitude check from the previous commit read 0x0000000012345678 as the high
word 0x12345678 instead of the low one, and tools/f64_diff.py's CPU reference
made the same mistake, so a generated program could agree with the translator on
the wrong operand.
tools/shader_ir.py records the literal's hex-digit count next to f64_literal
(and now marks v_ldexp_f64's sources too); tools/rdna2spirv.py decides with it at
all three literal readers, and tools/f64_diff.py's read_source mirrors the rule.
Tests: tests/semantic/test_f64_literal_whole.py gains the padded-width case
(0x0000000012345678 -> low word 0x12345678, high word 0) next to the 8-digit
control, and tests/test_f64_diff.py checks the reference reads both spellings the
same way.
ref_program began with EXEC = 0xffffffff, but the hardware kernel runs one lane, so EXEC is 1 there. Every v_cmpx case (the program reads exec_lo back with s_mov_b32 s22, exec_lo) therefore differed in one word, --oracle hw stopped at the first such case with a false mismatch, and the shrinker reduced it to an unrelated program. ref_program takes exec_lo (default unchanged for the translator and gpu oracles) and run_one passes 1 for hw; the FakeHW test double answers as a one-lane kernel. On gfx1036 the run now gives 294 match, 0 mismatch (it stopped at the first v_cmpx before).
Review follow-up on #4536 (CHANGES_REQUESTED by Flyander; coverage note by kapitche).
- --oracle hw no longer always exits 77. It opens tools/hw_oracle (same pattern as
tools/fmisc_diff.py), runs each program as a one-lane wave32 raw kernel in the game's
inferred MODE, honours --hw-arch, and compares the four words with the reference. 77 is
returned only when the oracle is unavailable. v_rcp/v_rsq/v_sqrt_f64 are counted skips
there (native results are approximations, PROC-216); the translator-only known-divergence
exclusions do not apply to hardware.
- add_bits: an exact zero sum now follows IEEE 754-2019 6.3. +0 + +0 stays +0 in every
mode; only opposite-signed zeros and x + (-x) give -0 when rounding toward negative.
Before, every exact zero was -0 in that mode.
- tests: direct table tests for compare (16 conditions x 28 operand pairs), class (10
classes plus boundaries), div_fixup, frexp and add_bits (NaN, inf, zero signs in all four
modes), plus fake-oracle tests for hw routing, --hw-arch, exit 77, skips and shrinking.
Mutating lt to <=, add_bits NaN to 0, or dropping the signed-zero rule now fails them.
- docs/shader_validation.md describes the hw contract. No AMD hardware run has been done.
KNOWN_DIVERGENCES keeps div-fixup-nan-s0 (it waits for TEST-983 to reach main).
AI-assisted (OpenBot team).
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>