Repository navigation
rdna2spirv: take a v_fma_mix literal from the printed encoding when only the text is cut (SHADER-FMA-MIX-TEXT-CUT-LITERAL) - #2142
Conversation
…nly the text is cut (SHADER-FMA-MIX-TEXT-CUT-LITERAL) llvm-mc 21.1.8 can print a v_fma_mix* literal cut to its low 16 bits in the text while the printed encoding keeps all 32 bits. The printed-encoding check then passes, so mix_literal (for a cut encoding) never runs and the text alone reads the high half as +0.0. restore_text_cut_mix_literal takes the literal from the printed encoding, on the clean and the re-anchoring paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
|
On an RTX 4090, the parent rendered 8/24 synthetic draws correctly and this head rendered 24/24. I compared
I exercised the first two rows on all three destinations, To reproduce the inputs, I extended the PR's AI-assisted with OpenAI Codex ( |
|
@ecox982745 thank you for running it on a GPU: 24/24 against 8/24 is the check I could not do here. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Verdict: ready to merge. This agrees with JordanWebDev's approval and ecox982745's GPU run. It adds a check with llvm-mc 21.1.8 itself, two mutations and a corpus sample. Three suggestions below, none blocking. Setup: PR head Tests
llvm-mc 21.1.8 check of the fixture. I gave the test's 12 stored bytes (
The PR matches all 10 runs; main matches none. The f32 row confirms the doc's "an f32 source a denormal": llvm-mc prints it as Mutation
Corpus sample (local only, counts only)
Safety
Suggestions (non-blocking)
Not covered by this review
AI-assisted: yes (Claude Code, Claude Opus 5.5, ran the tests and wrote this; a second agent checked this text) |
…n the low-half guard Review of ProjectLeonida#2142: the repair needs only the printed encoding, so it now runs before check_printed_encodings' early returns (no blob next to the listing, header-only blob). New tests: a listing with no blob gives the full literal, and a text immediate that is not the encoded literal's low half is left as the text says. design.md: the third shape now follows the second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
|
Thank you for the review and for checking the fixture against llvm-mc 21.1.8 directly. All three suggestions are in abcccef (plain push on the same branch, no rebase; it still merges cleanly with current
Ran (Reply written with Claude Code.) |
|
I checked the new listing-only path at RTX 4090, driver 616.64. I ran seven synthetic cases twice, once without an FSSM file and once with only its 256-byte header. The parent produced the expected pixels on 4/14 draws and the new head on 14/14. This covered positive and negative high halves, the low- and high-f16 destinations, an inline neighbor, genuinely truncated printed bytes, and the PR's text-mismatch control. Each SPIR-V module passed validation for Vulkan 1.2, and I checked every RGBA channel of each 64 × 64 draw. I found one edge case where an unrelated inline source satisfies the low-half comparison. This is a hand-written inconsistent listing, in the spirit of the new negative test. Whether LLVM emits this input in practice is unknown. These lines reproduce it with the PR's text = "v_fma_mix_f32 v1, v2, 1, lit(0x40000002) op_sel:[0,0,1] op_sel_hi:[0,0,1]"
data = listing(program(0x3c000001, "01 60 20 cc 02 03 fd 03", text))Here src1 is the inline integer 1, while src2 is the only encoded literal (selector In a local control I required the same source to have selector |
|
Independent confirmation, from another work copy of 1.0.2.1. Setup: the pipeline library, 2,684 compute programs, the same translator (main a73a57e), only llvm-mc changes. 2,683 modules translate on both sides.
Not covered: no GPU run. My count differs from the one in this PR (47,910 in 1,218 listings); I do not know why. AI-assisted: yes (Claude Code. Claude Fable 5.2 ran the comparison through sub-agents; a separate agent replayed the counts on other modules and wrote this wording.) |
|
Thank you for the independent check. On the count difference, here is exactly what the PR's figure counts, recounted over my local listings with the PR's own parser and the exact test
FSPX: 6 in 1 listing; the game's own 25,734 listings: 0. In these listings every literal-carrying So the two numbers measure different things: the PR counts instructions printed cut by llvm-mc 21, yours counts what differs between an llvm-mc 21 and an llvm-mc 23 translation. I can't reproduce your side here (no llvm-mc 23 on this machine), so I don't know why only 1,674 instructions / 383 modules differ in your comparison; one possibility, not checked, is that some of what 23 prints still translates to the same module. If you can share how many of your 383 modules fall within the 1,218 listings above, that would tell the two apart. On @Zalthor's batch listing #2142 as no longer applying: at head (Reply written with Claude Code.) |
|
Tested
The counts are identical to AI-assisted (Claude Code). No game data. |
|
Merging.
Thanks @DadaCap, @MoonEyes for the review, @JordanWebDev for the approval, and @ecox982745 and @Tauwni for the runs. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
|
I implemented the operand-specific follow-up from the merge review. An adjacent inline On a physical RTX 4090 (Windows 11, NVIDIA 616.64), 14/18 synthetic draws matched the expected pixels on main and 18/18 matched with the patch. The inline-neighbor case changed from 1.0 to the expected 2.0. When two sources selected the literal and only one printed the cut value, the result changed from 8.0 to the expected 10.0. Both cases were run with the native shader file absent and with a header only. All 18 translated modules on each revision passed Vulkan 1.2 SPIR-V validation. Both new inputs are hand-written inconsistent listings. Their frequency in compiler output is unknown. The full CPU translator suite passed all 6,369 tests across 500 files. The fork's branch is behind upstream workflow changes and GitHub rejected the branch sync with the current credentials. The linked patch is available for review or cherry-picking while the follow-up PR is pending. AI-assisted with OpenAI Codex (GPT-6). |
Claimed in the coordination issue as: SHADER-FMA-MIX-TEXT-CUT-LITERAL (#1608 (comment))
Depends on: nothing
What and why
llvm-mc 21.1.8 can print a
v_fma_mix*literal cut to its low 16 bits in the text only, while the printed encoding keeps all 32 bits. With the test's own values: the stored literal is0x40004200(low half 3.0, high half 2.0), the text says0x4200, and the printed encoding ends in00 42 00 40.same_encoding) passes, because the printed bytes are the stored ones.mix_literal(for an encoding that is cut too), never runs.restore_text_cut_mix_literaltakes the literal from the printed encoding when the text names only its low half and the high half is not zero. It runs on both the clean-listing path (check_printed_encodings) and the re-anchoring path (listings with undecodable words). The samerestore_mix_literalas before gives the 32 bits to every source the bytes encode as the literal.Counts over 1.0.2.1 (one work folder's listings, llvm-mc 21.1.8)
The FSPX program is the upscaler's history pass: one resampling weight lost its high half, so the weights summed to more than 1 and the history grew each frame.
Measured in the game
That one upscaler program retranslated with this change; RTX 5080, NVIDIA 621.24, Windows 11, a local tree with other open work:
That run had other local changes too, so it is not a clean A/B. The whole library retranslated with this change: 2,479 of 2,479 programs translate as before, none lost.
Tested
tests/semantic/test_fma_mix_literal.py: newtest_text_cut_but_printed_encoding_whole(clean and re-anchoring paths). It fails without the change (6.0 instead of 8.0) and passes with it; the file's other 18 tests pass.tests/test_docs_*.py,scripts/check_no_game_data.pyon the changed files.spirv-val.GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (the game run above; the hand-written GPU tests were not run)
AI-assisted: yes (Claude Code, Claude Opus 5.5 wrote the change, the test and this text)
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed.🤖 Generated with Claude Code