Repository navigation
Conversation
|
Checked the two retail reachability questions against all 26,503 stored 25,030 listings reported a clean disassembly and 1,473 reported at least one invalid word. These are counts over emitted listing text for the project's |
|
Tested 7c0aca1 on Intel UHD Graphics 630 (CFL GT2), Mesa ANV, subgroup 8..32: I translated the lit_literals and lit_f64_literals fixtures with the PR's tools, validated them with spirv-val (rc 0) and rendered them with vk_harness at 64x64. All 4096 pixels of ps_lit_literals are 0x40800000 0xc1000000 0x64 0x3f000000 and all 4096 pixels of ps_lit_f64_literals are 0x0 0xbf800000 0x3e800000 0xbf400000. test_shader_ir (37 tests), test_shader_meta (27), test_fma_mix_literal_probe (8), test_semantic_translator_use (3), test_vop3_const_mods (12), test_fma_mix_literal (7) and test_lit_literal (6) pass. I did not reproduce the failures on main or run the full tests/semantic suite. AI-assisted. |
|
Reviewed commit
AI-assisted (Gemini 4 Neon). |
|
Thanks, @Kev-Ball, @gertify and @DenRakEiw. @Kev-Ball's count. No retail listing carries One question about the count: which llvm-mc version wrote those listings? The build records it. I checked that llvm-mc 23.1.3 prints
So if your listings come from a version that prints @gertify (Intel UHD 630, ANV) and @DenRakEiw (Windows 11). Thanks. ANV matches the RTX 5080 words on all 4096 pixels for both fixtures, and your Windows unit run and Tests after the docs edit: AI-assisted (Claude Code). |
|
@cynbun The listings were produced with llvm-mc 23.1.5, target That confirms the disassembler used for the retail count emits the spelling on both positive controls. The zero applies to decoded instructions; 1,473 listings had at least one invalid word. AI-assisted. |
|
Thanks, @Kev-Ball. That settles it: llvm-mc 23.1.5 prints New head AI-assisted (Claude Code). |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed at 7c0aca1ce on Windows 11 / Python 3.13.
python tests/semantic/test_lit_literal.py: 6/6 OK.- Negative control: the same test copied onto main
561b65a83gives 3 failures + 2 errors (Unsupported operand lit(0x3f800000),Unsupported v_rcp_f64 operand), as described. pytest tests/test_shader_ir.py tests/test_shader_meta.py tests/test_fma_mix_literal_probe.py tests/test_semantic_translator_use.py -q: 75 passed, 79 subtests passed.- Checked operand parsing:
lit(hex|decimal)becomes the sameimmas a plain literal withliteral: true;-lit,|lit|,-|lit|andneg(lit(...))set the existing sign-bit flags;lit64, float spellings and values past 32 bits stayspecial. The f64 readers use the literal high word and the interpreter checks the expected words.
Verdict: LGTM. The GPU claim is external to the PR (no GPU fixture is added); the CPU/IR evidence is solid.
larpinguser
left a comment
There was a problem hiding this comment.
Summary
tools/shader_ir.py now parses LLVM's lit(0x...) operand as the literal imm (tagged literal so 64-bit sources distinguish it from an inline constant), with -lit, |lit|, -|lit|, neg(lit) as sign-bit modifiers; lit64(), floats and >32-bit values stay Unsupported. tools/rdna2spirv.py and tools/fma_mix_literal_probe.py are adjusted. Adds tests/semantic/test_lit_literal.py plus two llvm-mc fixtures and a docs/design.md row.
Why merge
Stops the translator rejecting hand-written/disassembled lit() operands (Unsupported operand lit(...)) that LLVM emits when a literal shadows an inline constant, without changing any retail translation.
Verdict: Approve
Summary
Why mergeStops the translator rejecting hand-written/disassembled Verdict: Approve |
59330bf to
653823d
Compare
|
Tested 653823d merged onto main 7ef2fdd on RTX 5070 (Blackwell), NVIDIA Windows driver 32.0.16.2124 (621.24), Windows 11 Pro 26300, CPython 3.11.0; no llvm-mc, no SPIRV-Tools, with the CI runtime-windows test programs of main 7b7d73f (the runner is newer than those programs): fail The merge is clean in git, but main now has #6808 (513294b, "read LLVM 23's lit(V) operand as the constant V"), which rewrites every
The PR needs a rebase onto #6808. As things stand, the remaining differences from main are the AI-assisted (Claude Code). |
…s none of ItsNotRexed#6808 reads LLVM's lit(V) as the constant V. llvm-mc's assembler encodes lit(V) as the literal dword V even when V is an inline constant, but the 64-bit float readers tell a literal from an inline constant by value (v_cmp_*_f64, v_ldexp_f64) or by a 0x spelling (parse_line's f64_literal), so a decimal lit(1) on v_add_f64, or lit(0x1) on v_cmp_*_f64 / v_ldexp_f64, read as the inline integer 1 in bits 31:0 instead of the literal in bits 63:32. operand() now marks the imm "literal", parse_line and v_ldexp_f64 honour the mark (read_f64_words and cmp_class_f64 already did), and lit(-1), lit(1.0), a value past one dword and lit64() stay "special" (Unsupported) instead of reading as an imm/fimm whose meaning depends on the operand type. LLVM's disassembler prints lit() only in hex and only where the literal and the inline constant give the same value, so no translation of its listings changes. tests/semantic/test_lit_literal.py (new fixture lit_f64_inline_range.asm) fails on main and passes here; ItsNotRexed#6808's operand test now expects the mark. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
653823d to
0ccb1a3
Compare
|
Thanks, @duudiis. You're right: after #6808, this PR's What it adds over #6808. I checked your two points on main first.
To be clear about the scope: LLVM's disassembler prints Tests. The old fixtures and their GPU results are dropped, because they pass on main too.
If you or the maintainers think hand-written-text correctness isn't worth a PR on its own, I'm fine with closing it in favour of #6808. AI-assisted (Claude Code). |
|
I checked the rewritten fixture on I rendered each module with the same fullscreen vertex shader and The same two modules also ran on the physical RTX 3080 Ti (620.73.04, CachyOS). All 4,096 pixels per revision matched the corresponding llvmpipe result above, including all four export words. The direct parent fails the rewritten fixture’s expected output, and the PR passes. |
|
Tested
AI-assisted. |
|
Tested
|
|
checked partial: at your head, |
Item:
lit()operand gap intools/shader_ir.py(claimed in #5581: #5581 (comment)).Depends on: #6808 (merged, 513294b). Rebased onto it: #6808 already reads
lit(V)as the constant V, so this PR now only adds what #6808 doesn't do.What #6808 leaves open
llvm-mc's assembler (23.1.3,
-mcpu=gfx1030) encodeslit(V)as the literal dword V, even when V is also an inline constant. On a 64-bit float source, that literal dword is bits 63:32 and bits 31:0 are zero (the "f64 literal sources" row). The translator's f64 readers tell a literal from an inline constant in two ways:parse_line'sf64_literal(v_add_f64,v_cvt_f32_f64,v_rcp_f64, …) checks for a0xspelling.read_f64_words(v_cmp_*_f64),cmp_class_f64andv_ldexp_f64check the value, plus aliteralmark that nothing set.So on main:
v_add_f64 v[0:1], lit(1), v[2:3]00 00 64 d5 ff 04 02 02 01 00 00 00v_cmp_gt_f64_e32 vcc_lo, lit(1), v[2:3]ff 04 48 7c 01 00 00 00v_ldexp_f64 v[4:5], lit(0x1), v6(hex too)04 00 68 d5 ff 0c 02 02 01 00 00 00#6808 also reads
lit(-1),lit(1.0)andlit(0x100000000)as animm/fimm. llvm-mc encodes the first two as a literal of the operand's type, so their value depends on the operand. It rejects the third ("literal value out of range").lit64()was already refused on main.Scope: LLVM's disassembler prints
lit()only in hex, and only where the literal and the inline constant give the same value (for an f64 source: 0, and the high words of the inline doubles). So this PR changes no translation of a disassembly listing. It covers hand-written text. No retail listing haslit(at all: @Kev-Ball's count over 26,503gfx1013listings, made with llvm-mc 23.1.5, which printslit().Change
tools/shader_ir.py: one_LIT, narrowed to an unsigned hex or decimal value of at most one dword.operand()marks the resulting imm"literal": True, and the mark survives-,|..|,-|..|andneg(..).lit(-1),lit(1.0), a value past one dword andlit64(..)stayspecial, which isUnsupported.parse_linetreats the mark like a0xspelling when it setsf64_literal.tools/rdna2spirv.py:v_ldexp_f64honours the mark.read_f64_wordsandcmp_class_f64already did.tools/fma_mix_literal_probe.py: the docstring no longer says the translator can't parselit(). That stopped being true with shader_ir: read LLVM 23's lit(V) operand as the constant V #6808.tests/test_shader_ir.py: shader_ir: read LLVM 23's lit(V) operand as the constant V #6808'stest_llvm23_lit_is_the_constantnow expects the same imm plusliteral.docs/design.md: new row "lit()literals" after "f64 literal sources".Tests
tests/semantic/test_lit_literal.pywith the hand-written fixturefixtures/lit_f64_inline_range.asm. Each line is assembled by llvm-mc 23.1.3 to the bytes in its comment.v_cmp_gt_f64withlit(1)andv_ldexp_f64withlit(0x1). Expected words:0x3f800000 0x41f00000 0x0 0x0. Main gives0x0 0x3ff00000 0x0 0x0.v_add_f64 lit(1),v_cvt_f32_f64 lit(64)andv_rcp_f64 lit(2)in the SPIR-V are (0, V). Main gives (V, 0).spirv-val --target-env vulkan1.2: the translated fixture and the three single-line modules are valid.python -I scripts/run_semantic_tests.py tests/semantic: 448 files, 5963 tests. 2 files fail,test_image_atomics_guardandtest_image_store_d16, and they fail the same way on main 976b3ec.tests/test_shader_ir.py,tests/semantic/test_fma_mix_literal.py,tests/test_fma_mix_literal_probe.py,test_alu_ldexp_f64,test_cmp_f64,test_cmp_class_f64,test_alu_cmp_class_f16_f64.Seen, not changed here
0x1literal onv_cmp_*_f64orv_ldexp_f64(which the disassembler does print, as0x1) is still read as the inline 1, because those readers decide by value. The corpus has nov_cmp*_f64at all (the same count).AI-assisted (Claude Code).
🤖 Generated with Claude Code