fix: sign-extend a 32-bit literal in the signed 64-bit scalar sources (s_ashr_i64, s_bfe_i64, s_flbit_i32_i64) #240
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!240
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/240/head"
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?
@lcg007xd-c on GitHub · 2026-11-25 20:49 UTC · original
lcg007xd-c:fix/salu-i64-literal-sign-extend→main· +39 −3 · 2 files · 1 commits · merged 2026-11-25 21:07 UTCChange
s_ashr_i64,s_bfe_i64ands_flbit_i32_i64read S0 as a signed 64-bit integer, but in the reference interpreter a 32-bit literal in S0 was zero-extended like any other 64-bit scalar source. Silent wrong values onmain(4f2cf5c):Source: AMD, "RDNA 2" ISA, November 2020, §6.2.1, "Literal Expansion to 64 bits" (printed p. 43): "Literal constants are 32-bits, but they can be used as sources which normally require 64-bit data. They are expanded to 64 bits following these rules: 64 bit float: the lower 32-bit are padded with zero. 64-bit unsigned integer: zero extended to 64 bits. 64-bit signed integer: sign extended to 64 bits." The operand types come from the same document:
D.i64 = signext(S0.i64) >> S1.u[5:0](S_ASHR_I64, §12.1),S0.i64for S_BFE_I64, and S_FLBIT_I32_I64 counts the bits equal to the sign bit (§12.3).A small wrapper,
rdna2_exec_bits.signed_literal_s0, sign-extends the literal before these three instructions run. The unsigned and bitwise 64-bit sources keep zero-extending (s_bfe_u64,s_mov_b64,s_flbit_i32_b64, the_b64logic). The test pins that too.HLSL: no change. The recompiler does not translate these three instructions (
Untranslatable: non traduite en HLSL : s_ashr_i64…), so there is nothing to keep in parity.Linked issue: none. VIctory settled the same ISA rule for its own lowering (
signed_64_bit_operands_sign_extend_their_literal, cited in Marvisak/VIctory#2254); no code is taken from it.Verification
Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip):
The 6 failures are the same as on
mainon this machine and unrelated: 2 intest_jour_j.py(manifest name case on Linux, #237) and 4 intest_rdna2_exec_fma.py(NaN quieting on Python 3.14, #238).Not run: the Windows CI job and GPU/WARP (no HLSL change).
Oracle and test data
test_signed_64_bit_sources_sign_extend_a_32_bit_literal(tests/test_rdna2_exec_bits.py) computes the expected values by hand from the ISA pseudo-code:s_ashr_i64of0x80000000(with SCC) and of the positive0x7FFFFFFF, ands_bfe_i64againsts_bfe_u64on the same literal and field. It also checkss_flbit_i32_i64againsts_flbit_i32_b64on0xFFFFFFF0, and thats_mov_b64still zero-extends.main(pair(wave, 40) == 0x40000000, expected0xFFFFFFFF_C0000000).Checklist
E_NOTIMPL), never a fake success.test_readme_sync.pychecks it). (No README change: no new encodings, still1300+.)Made with AI assistance (Claude Code).
🤖 Generated with Claude Code