Repository navigation
Conversation
…tterns (TEST-67) The interpreter keeps floats as Python floats, and struct '<f' / a double quiets a signalling NaN (bit 22), so a word in 0x7f800001..0x7fbfffff or 0xff800001..0xffbfffff came back changed after OpBitcast int->float->int or an export (ProjectLeonida#509: 0xffa3a095 became 0xffe3a095, about 0.4% of random words). bits_f32 now returns a SignallingNaN for such a pattern: a float subclass whose value is the quiet NaN Python makes of it, so arithmetic is unchanged, and f32_bits returns the original pattern. OpBitcast, OpCopyObject, OpSelect, stores and outputs carry the word exactly; an operation on it still gives the quiet NaN, as IEEE 754 says. test_interp.py covers int->float->int, copies, selects, a float output and the arithmetic case; they fail with the interpreter from main. The seeded test_mem_diff s_load case (seed 20261122), which failed on main with 0x7fc295f4 for 0x7f8295f4, passes again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent Windows x64 / Python 3.12.10 CPU validation on detached commit
I also ran the failing cases in a separate clean worktree of main at
Both failures disappear with this exact PR head. This independently confirms that the two interpreter-related failures inherited by #388 are addressed. These are synthetic CPU-only tests; no GPU or game data was used. This report does not claim the whole project CI is green: the separate llvmpipe subgroup issue is TEST-78. I tested both current TEST-67 proposals under the same environment and am reporting exact-head evidence on each, without proposing a third fix or changing either author's code. The choice/coordination between them remains with the authors and maintainer. |
Claimed in #374 as: TEST-67
Fixes #509.
What and why
tests/semantic/spirv_mini_interp.pykeeps float values as Python floats, and Python quiets a signalling NaN (sets bit 22) when it goes throughstruct<for a double. A word in0x7f800001..0x7fbfffffor0xff800001..0xffbffffftherefore came back changed afterOpBitcastint -> float -> int or an export of an integer result:0xffa3a095became0xffe3a095, about 0.4% of random words. It broke the seededv_ashrrev_i64case in #454, and it breakstests/test_mem_diff.pytoday:family='s_load'with the date-based seed 20261122 expects0x7f8295f4and got0x7fc295f4.bits_f32now returns aSignallingNaNfor such a pattern: afloatsubclass whose value is the quiet NaN Python makes of the pattern, plus the original 32-bit pattern.f32_bitsreturns that pattern. SoOpBitcast,OpCopyObject,OpSelect, stores and outputs carry the word exactly, while arithmetic is unchanged (the result is the quiet NaN with the same sign and payload, as IEEE 754 says). Nothing else in the interpreter or the translator changes.The copy of
f32_bitsintest_ballot_votes.py(the wave interpreter) has the same property; it is a separate interpreter and not part of #509, so I left it alone.Tested
tests/semantic/test_interp.py(the interpreter's own self-tests) gets three tests: int -> float -> int, throughOpCopyObjectandOpSelectas well, for0xffa3a095,0x7f800001,0x7fbfffff, a quiet NaN, infinity and0xffffffff; a floatOutputvariable; and anOpFAddon a signalling NaN, which must still return the quiet NaN (0xffe3a095). With the interpreter from main the new tests fail (6 failing cases); with this change all 31 tests pass.python -I -m unittest discover -s tests/semantic -p "test_*.py": 711 tests OK.python -I tests/semantic/regen_fixtures.py --check: OK.python -I -m unittest discover -s tests -p "test_*.py"): 1326 tests, no failures; the only errors are 14 modules that need pytest, which isn't installed here. On main the same run has thetest_mem_diffs_loadfailure above.AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code