Repository navigation
Conversation
…too (SHADER-865) docs/design.md "f64 literal sources": a 32-bit literal on a binary64 source supplies bits 63:32 with a zero low word. shader_ir.py flagged this only for v_add_f64, v_cvt_f32_f64 and the four rounding ops, so v_rcp_f64, v_rsq_f64, v_sqrt_f64, v_frexp_mant_f64 and v_frexp_exp_i32_f64 read the literal into bits 31:0: v_frexp_exp_i32_f64 of 1.5 (0x3ff80000) gave -1044, and the three %double ops built 0x000000003ff80000. The flag now covers the five ops; the rcp/rsq/sqrt reader already honoured it, frexp gets the branch (a hand-written 64-bit literal keeps its whole value, an inline integer stays sign-extended). The design row lists the ops. tests/semantic/test_f64_literal_ops.py: the constants the three double ops build, frexp of a literal on the interpreter, the inline-integer and 64-bit-literal controls; four of the five fail on main. v_div_fixup_f64 / v_div_fmas_f64 are ItsNotRexed#3791's. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
|
Tested 3eafef2 on Windows 11, CPython 3.14.7, CPU only: pass. I checked 100 synthetic f64 values with positive and negative signs and normal exponents (seed 5534). For each input, I placed the literal word in bits 63:32 and set bits 31:0 to zero. The translated frexp instructions returned the same exponent and mantissa bits as Python's I ran Against parent 3faac55, the new tests detect the wrong word position for all five instructions. For example, the exponent of 1.5 is -1044 on the parent and 1 on the head. I checked the emitted operands for reciprocal, reciprocal square root, and square root. The frexp checks execute the translated shader in the CPU interpreter. AI-assisted. |
|
Code read + CPU tests, 3eafef2: pass for this change. Full semantic suite on this branch: 4 failures + 2 errors, and they are the known ones, not this one:
So the f64 literal-placement change adds nothing red; once #3995 lands the only remaining red should be the toolchain-dependent one. |
|
Tested
No game files. AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Review at head 3eafef2fb (Windows 11, CPU).
Commands:
python tests/semantic/test_f64_literal_ops.py
python -I -m pytest tests/test_shader_ir.py -q
python tests/semantic/test_valu_rcp_f64.py # and rsq/sqrt/frexp_* files
git diff --check 3faac557b..HEAD
Results: 5 semantic tests OK; test_shader_ir 37 passed, 18 subtests; rcp 54, rsq 64, sqrt 53, frexp_mant 53, frexp_exp 50, frexp_f64 65, alu_frexp_f64 9, vop3_const_mods 11 — all OK.
Negative control with LEONIDA_TOOLS_DIR pointing at a clean 3faac557b tools dir: 5 of 5 tests fail, including the three %double constants and both frexp reads, so the test detects the bug.
Verdict: approve. Overlaps #3791 (two division ops, same shader_ir.py line and design row) — whichever lands second takes a one-line union.
Claimed as SHADER-865 in the coordination issue (TreXito's finding). The two division ops of the item,
v_div_fixup_f64andv_div_fmas_f64, are #3791's; this PR takes the other five and touches the sameshader_ir.pyline anddesign.mdrow, so whichever lands second resolves a one-line union.docs/design.md"f64 literal sources": a 32-bit literal on a binary64 source supplies bits 63:32 with a zero low word.shader_ir.pyset thef64_literalflag only forv_add_f64,v_cvt_f32_f64and the four rounding ops, sov_rcp_f64,v_rsq_f64,v_sqrt_f64,v_frexp_mant_f64andv_frexp_exp_i32_f64read the literal into bits 31:0:v_frexp_exp_i32_f64of 1.5 (0x3ff80000) gave -1044, and the three%doubleops built0x000000003ff80000.The flag now covers the five ops. The rcp/rsq/sqrt reader already honoured it; the frexp reader gets the branch, keeping a hand-written 64-bit literal whole and an inline integer sign-extended. The design row names the ops.
Tests (
tests/semantic/test_f64_literal_ops.py, translator-backed): the 64-bit constants the three double ops build;frexp_expandfrexp_mantof a literal on the interpreter (1 and 0.75); an inline-1and a 64-bit literal as controls. With main'stools/(LEONIDA_TOOLS_DIR) four of the five fail in the finding's way.Tested: Windows 11 (Python 3.12.10) at 3eafef2,
test_f64_literal_ops5 OK; macOS the same, plustest_vop3_const_mods11, the frexp/rsq/rcp/sqrt f64 suites,test_alu_div_fmas9,test_cmp_f645,tests/test_shader_ir.py37 and the two docs tests OK. No game files.AI-assisted (Claude Code, Claude Fable 5.1).
🤖 Generated with Claude Code
https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz