Repository navigation
rdna2spirv: v_cmp*_f64 small literals are upper-half dwords - #5104
tupacfan04 wants to merge 1 commit into
Conversation
|
Tested Please correct the expected value in the new test comment. An upper dword of 1 and a lower dword of 0 encode 2^-1042. The comment says 2^-32. To check the value independently: import struct
assert struct.unpack("<d", struct.pack("<II", 0, 1))[0] == 2**-1042I also ran two synthetic AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Ran this at f387d76d1 on Windows 11: tests/semantic/test_cmp_f64.py -> 6 tests, OK; git diff --check clean.
v_cmp*_f64 with a small literal now reads the literal as the comparison's upper-half dword (the form shader_ir prints), instead of taking the low half and comparing the wrong value; the added cases cover the literal forms next to the register and pair forms. No blocking issue.
22c31fa to
3ceecb6
Compare
|
Thanks @shdann — corrected in 3ceecb6. A high dword of 1 is 2^-1042 (not 2^-32), and the test now also asserts exact equality with the (low 0, high 1) pair, not just inequality with the inline 1 pair. |
|
Tested At Against a register pair (low 1, high 0), the hexadecimal literal AI-assisted verification. |
kacper-serewis
left a comment
There was a problem hiding this comment.
Integrated #5115 cb6bcea with #5104 3ceecb6 in private scratch. Six hand-encoded ordinary f64 equality compares distinguished inline 1 from literal dword 1 through formatting, parsing, translation and CPU interpretation, including e64 right-hand operands. All six focused compare tests passed. Across 26,503 cached listings there were no static f64 compares, and all 468 source operands at the identified f64 sites were registers. Applicability of the literal case comes from the synthetic tests. AI-assisted, CPU only.
|
Tested
|
|
Independent Windows CPU verification on
|
A 32-bit literal on a binary64 compare supplies bits 63:32, but read_f64_words checked a dead literal key and shader_ir marked f64_literal only for six arithmetic ops. Small hex literals such as 0x1 were therefore treated as inline integers and compared against 5e-324 instead of 2^-32. Mark compare literals with the same hex/decimal rule and read the key the parser writes.
3ceecb6 to
886dcab
Compare
|
Rebased onto Re-ran after the rebase: |
|
Gap found while working on the same rule (checked against llvm-mc 23.1.3, gfx1030, on top of main |
|
Thanks. I checked the class path before scoping it out:
|
|
You're right, thanks — I withdraw the |
Claimed in the coordination issue: #5032 (comment)
Depends on: none. #2863, #3642 and #3791 extend
f64_literalfor arithmetic f64 ops in the same parser area; this is the compare path, so they should merge independently, but whichever lands second rebases.What and why
A 32-bit literal on a binary64 compare supplies bits 63:32, with bits 31:0 zero.
read_f64_wordschecked a dead"literal"key, andshader_irmarkedf64_literalonly for six arithmetic ops. Small hex literals onv_cmp*_f64were therefore treated as inline integers:v_cmp_eq_f64_e64 s4, 0x1, v[4:5]compared against 5e-324 (inline 1, 2^-1074) instead of 2^-1042 (the high dword0x1).The parser now marks compare literals with the same hex/decimal rule it uses for arithmetic f64 sources, over both compare operands (e64 has a destination first; e32 does not), and
read_f64_wordsreads the key the parser actually writes.v_cmp*_class_f64is excluded because it has its own literal path.Tested
python -I tests/semantic/test_cmp_f64.py: 6 tests, OK. The new case checks inequality with the inline 1 pair and exact equality with the (low 0, high 1) pair.main561b65a'stools/shader_ir.pyandtools/rdna2spirv.pyfails the new case withgot [1, 1, 0, 0], expected[0, 1, 1, 0].561b65a8(head886dcabee); the conflict was main's expanded f64 op list inshader_ir.py, resolved by keeping both. Re-ran:test_cmp_f64.py6/6,test_cmp_class_f64.py6/6,test_valu_rcp_f64.py54/54,test_valu_rsq_f64.py64/64,test_valu_sqrt_f64.py53/53,test_valu_frexp_mant_f64.py53/53,test_valu_frexp_exp_i32_f64.py50/50.tests/semantic/test_loop_ballot_barrier.py; clean main gave the same 15-test file result. The rebase only merged main's expanded f64 op list into the same helper.python -m compileall -q make_game.py tools tests: exit 0.Out of scope:
tools/rdna2_decode.pyprints a small f64 literal word as decimal, which loses the same distinction for Python-backend disassembly; that is a separate item.AI-assisted: yes (OpenCode).
Checklist
docs/design.md, with how it was confirmed. (no new rule; this restores the documented f64 literal-source rule)