fix: inline float constants in 64-bit scalar operands are the f64 value (s_mov_b64 s[0:1], 1.0) #239

Manually merged
github merged 1 commit from gh-pr/239/head into gh-pr/239/base 2026-11-26 05:39:29 +00:00
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 20:48 UTC · original
lcg007xd-c:fix/salu64-inline-f64 → main · +55 −0 · 2 files · 1 commits · merged 2026-11-25 21:07 UTC

Change

In the reference interpreter, Wave.read_scalar(code, literal, width=2) returned the float32 pattern of the inline float constants (codes 240-248), zero-extended, for 64-bit scalar sources. That is a silent wrong value on main (4f2cf5c):

s_mov_b64 s[0:1], 1.0     → 0x00000000_3F800000   (should be 0x3FF00000_00000000)
s_mov_b64 s[2:3], -0.5    → 0x00000000_BF000000   (should be 0xBFE00000_00000000)
s_or_b64  s[4:5], 0, 4.0  → 0x00000000_40800000   (should be 0x40100000_00000000)
s_cmp_eq_u64 s[0:1], 1.0  → compares against 0x3F800000

Sources:

  • AMD, "RDNA 2" ISA, November 2020, §5.2 "Scalar ALU Operands" (printed p. 32): codes 240-248 are "single or double floats", with 1/(2π) "single: 0x3e22f983, double: 0x3fc45f306dc9c882".
  • LLVM 20 (cross-check): llvm-mc -triple=amdgcn -mcpu=gfx1030 -show-encoding assembles s_mov_b64 s[0:1], 0x3ff0000000000000 to the 4-byte [0xf2,0x04,0x80,0xbe], which is inline code 242 (1.0). Code compiled by LLVM depends on this rule to load f64 constants.

Now a 64-bit read of codes 240-248 returns the double (rdna2_exec_cmp64.INLINE_DOUBLES, already used for the f64 compares). This affects every 64-bit SALU source that goes through read_scalar: s_mov_b64, s_cmov_b64, s_cselect_b64, s_{and,or,xor,…}_b64, s_cmp_eq/lg_u64, s_bitcmp*_b64 S0, the 64-bit saveexec forms. 32-bit reads keep the float32 pattern.

HLSL: no change. rdna2_hlsl_ops.source_high already raises Untranslatable for an inline float in a 64-bit operand, so the recompiler refuses these instructions instead of producing the old wrong value; a test pins that. Translating them is left for a follow-up with GPU parity tests.

Also not touched: the interpreter's 64-bit VALU integer sources (v_lshlrev_b64, v_cmp_*_u64 …) still refuse an inline float (read64 with is_float=False), while HLSL's rdna2_hlsl_wide._words already uses the double there.

Linked issue: none. The same rule was settled in VIctory (Marvisak/VIctory#1577, "expand 64-bit inline constants as signed ints and binary64 floats"); no code is taken from it.

Verification

Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip):

python -m pytest                → 6 failed, 1020 passed, 315 skipped
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

The 6 failures are the same as on main on this machine, all unrelated: 2 in test_jour_j.py (manifest name case on Linux, #237) and 4 in test_rdna2_exec_fma.py (NaN quieting on Python 3.14, #238).

Not run: the Windows CI job and the GPU/WARP tests (no HLSL change).

Oracle and test data

  • New tests/test_rdna2_exec_inline64.py (12 tests): s_mov_b64 with each of the 9 codes against the f64 patterns written by hand (1/(2π) from the ISA table); s_or_b64, s_cmp_eq_u64 and s_cselect_b64 with inline floats; 32-bit s_mov_b32 still gets 0x3F800000 and 0x3E22F983; the HLSL recompiler raises Untranslatable for s_mov_b64 s[40:41], 1.0.
  • Failure case: 10 of the 12 fail on main (the two that pass are the 32-bit control and the HLSL refusal).
  • Not measured on hardware here: no RDNA 2 GPU was available. The evidence is the ISA table and LLVM's encoding.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (HLSL keeps refusing these operands by name.)
  • README: the same change in all 9 languages (test_readme_sync.py checks it). (No README change: no new encodings, still 1300+.)
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

Made with AI assistance (Claude Code).

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:48 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/239) `lcg007xd-c:fix/salu64-inline-f64` → `main` · +55 −0 · 2 files · 1 commits · merged 2026-11-25 21:07 UTC ## Change In the reference interpreter, `Wave.read_scalar(code, literal, width=2)` returned the **float32** pattern of the inline float constants (codes 240-248), zero-extended, for 64-bit scalar sources. That is a silent wrong value on `main` (`4f2cf5c`): ``` s_mov_b64 s[0:1], 1.0 → 0x00000000_3F800000 (should be 0x3FF00000_00000000) s_mov_b64 s[2:3], -0.5 → 0x00000000_BF000000 (should be 0xBFE00000_00000000) s_or_b64 s[4:5], 0, 4.0 → 0x00000000_40800000 (should be 0x40100000_00000000) s_cmp_eq_u64 s[0:1], 1.0 → compares against 0x3F800000 ``` Sources: - AMD, "RDNA 2" ISA, November 2020, §5.2 "Scalar ALU Operands" (printed p. 32): codes 240-248 are "**single or double floats**", with 1/(2π) "single: 0x3e22f983, **double: 0x3fc45f306dc9c882**". - LLVM 20 (cross-check): `llvm-mc -triple=amdgcn -mcpu=gfx1030 -show-encoding` assembles `s_mov_b64 s[0:1], 0x3ff0000000000000` to the 4-byte `[0xf2,0x04,0x80,0xbe]`, which is inline code 242 (1.0). Code compiled by LLVM depends on this rule to load f64 constants. Now a 64-bit read of codes 240-248 returns the double (`rdna2_exec_cmp64.INLINE_DOUBLES`, already used for the f64 compares). This affects every 64-bit SALU source that goes through `read_scalar`: `s_mov_b64`, `s_cmov_b64`, `s_cselect_b64`, `s_{and,or,xor,…}_b64`, `s_cmp_eq/lg_u64`, `s_bitcmp*_b64` S0, the 64-bit `saveexec` forms. 32-bit reads keep the float32 pattern. HLSL: no change. `rdna2_hlsl_ops.source_high` already raises `Untranslatable` for an inline float in a 64-bit operand, so the recompiler refuses these instructions instead of producing the old wrong value; a test pins that. Translating them is left for a follow-up with GPU parity tests. Also not touched: the interpreter's 64-bit *VALU* integer sources (`v_lshlrev_b64`, `v_cmp_*_u64` …) still refuse an inline float (`read64` with `is_float=False`), while HLSL's `rdna2_hlsl_wide._words` already uses the double there. Linked issue: none. The same rule was settled in VIctory (Marvisak/VIctory#1577, "expand 64-bit inline constants as signed ints and binary64 floats"); no code is taken from it. ## Verification Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip): ``` python -m pytest → 6 failed, 1020 passed, 315 skipped python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` The 6 failures are the same as on `main` on this machine, all unrelated: 2 in `test_jour_j.py` (manifest name case on Linux, #237) and 4 in `test_rdna2_exec_fma.py` (NaN quieting on Python 3.14, #238). Not run: the Windows CI job and the GPU/WARP tests (no HLSL change). ## Oracle and test data - New `tests/test_rdna2_exec_inline64.py` (12 tests): `s_mov_b64` with each of the 9 codes against the f64 patterns written by hand (1/(2π) from the ISA table); `s_or_b64`, `s_cmp_eq_u64` and `s_cselect_b64` with inline floats; 32-bit `s_mov_b32` still gets `0x3F800000` and `0x3E22F983`; the HLSL recompiler raises `Untranslatable` for `s_mov_b64 s[40:41], 1.0`. - Failure case: 10 of the 12 fail on `main` (the two that pass are the 32-bit control and the HLSL refusal). - Not measured on hardware here: no RDNA 2 GPU was available. The evidence is the ISA table and LLVM's encoding. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (HLSL keeps refusing these operands by name.) - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). (No README change: no new encodings, still `1300+`.) - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. Made with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Wave.read_scalar returned the float32 pattern of codes 240-248 for 64-bit
reads too, zero-extended: s_mov_b64 s[0:1], 1.0 gave 0x00000000_3F800000.
The RDNA 2 ISA (section 5.2, p. 32) gives these codes as "single or double
floats" (1/(2pi) double 0x3fc45f306dc9c882), and llvm-mc 20 (gfx1030)
assembles s_mov_b64 s[0:1], 0x3ff0000000000000 to inline code 242, so a
64-bit scalar read now returns the double: s_mov_b64, s_cselect_b64, the
64-bit logic ops, s_cmp_eq/lg_u64, the 64-bit saveexec forms. 32-bit reads
keep the float32 pattern. The HLSL recompiler still refuses these operands
(source_high), which a test pins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:39:27 +00:00
github manually merged commit 07a43c68dc into gh-pr/239/base 2026-11-26 05:39:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.