[PR #1662] [MERGED] rdna2spirv: the exact re-anchor keeps a signed-byte dot's stored op_sel_hi (SHADER-DOT4-SEL-EXACT-ANCHOR) #1677

Closed
opened 2026-11-26 20:22:04 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1662
Author: @Tyrannys
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: dot4-sel-exact-anchor


📝 Commits (1)

  • b3ce84b rdna2spirv: the exact re-anchor keeps a signed-byte dot's stored op_sel_hi (SHADER-DOT4-SEL-EXACT-ANCHOR)

📊 Changes

3 files changed (+108 additions, -2 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_reanchor_dot4_inline_sel.py (+105 -0)
📝 tools/rdna2spirv.py (+2 -1)

📄 Description

Claimed in the coordination issue as: SHADER-DOT4-SEL-EXACT-ANCHOR (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155365083)

What and why

translate() re-anchors a listing that reports rejected words. When llvm-mc's messages give one offset per rejected word, it re-anchors exactly, from those offsets (invalid_at). That exact path tried mix_literal and mix_inline_literal, but not restore_dot4_inline_sel. The forward search and check_printed_encodings already try that repair. So a v_dot4_i32_i8 with an inline-integer S1 and a stored op_sel_hi of 5 (llvm-mc prints it as the default, 7) got marked normalized, and its whole program was refused with "reachable instruction with normalized encoding".

One of the FidelityFX DLL's programs has this form, plus rejected words. Without it, the title's slot-67 pipeline creation fails. In a retail boot, the upscaler then crashes on a null read a few seconds later.

The fix: the exact path tries restore_dot4_inline_sel first, in the same order as the forward search. Other mismatches are refused as before. The change is one line. It doesn't touch #1301's lines in restore_dot4_inline_sel itself.

docs/design.md (the "Code-embedded data" row) records the rule and the count.

Tested

No game files in the test. Windows 11, CPU only for the suite.

  • New tests/semantic/test_reanchor_dot4_inline_sel.py, hand-built encodings:
    • the exact path now translates the form, with the same result as the clean-listing path;
    • that result is the stored op_sel_hi, not the printed one;
    • a register-S1 mismatch is still refused.
    • Before the fix, the first two fail with the error above.
  • python -I scripts/run_semantic_tests.py tests/semantic: 488 files, 6,282 tests, 0 failed (292 s, 16 jobs).
  • Counted on my own 1.0.2.1 copy (LLVM 21.1.8, --wave64-emulate), the FidelityFX DLL's 29 programs:
    • main: 22 translated;
    • this PR: 24;
    • this PR with #674 (SHADER-VCC-TUPLE-RESYNC) on top: 29 of 29, all pass spirv-val;
    • #674 alone: 28.
    • So the two PRs are independent, and both are needed for the whole DLL.
  • Retail boot with all 29 programs (RTX 4070 SUPER, NVIDIA 621.01; LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WATCHDOG=0, plus #1631): the upscaler crash that ended the runs before is gone, and the run lasted its full 485 s. A device loss on a library compute dispatch came late in the run. That's a separate matter.

AI-assisted (Claude Code).

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (retail boot only; the translator tests need no GPU)

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1662 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `dot4-sel-exact-anchor` --- ### 📝 Commits (1) - [`b3ce84b`](https://github.com/ubiquitarianism/leonida/commit/b3ce84b33fd96a525da8fcc22089f53826477477) rdna2spirv: the exact re-anchor keeps a signed-byte dot's stored op_sel_hi (SHADER-DOT4-SEL-EXACT-ANCHOR) ### 📊 Changes **3 files changed** (+108 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_reanchor_dot4_inline_sel.py` (+105 -0) 📝 `tools/rdna2spirv.py` (+2 -1) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-DOT4-SEL-EXACT-ANCHOR (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155365083) ### What and why `translate()` re-anchors a listing that reports rejected words. When llvm-mc's messages give one offset per rejected word, it re-anchors exactly, from those offsets (`invalid_at`). That exact path tried `mix_literal` and `mix_inline_literal`, but not `restore_dot4_inline_sel`. The forward search and `check_printed_encodings` already try that repair. So a `v_dot4_i32_i8` with an inline-integer S1 and a stored op_sel_hi of 5 (llvm-mc prints it as the default, 7) got marked normalized, and its whole program was refused with "reachable instruction with normalized encoding". One of the FidelityFX DLL's programs has this form, plus rejected words. Without it, the title's slot-67 pipeline creation fails. In a retail boot, the upscaler then crashes on a null read a few seconds later. The fix: the exact path tries `restore_dot4_inline_sel` first, in the same order as the forward search. Other mismatches are refused as before. The change is one line. It doesn't touch #1301's lines in `restore_dot4_inline_sel` itself. `docs/design.md` (the "Code-embedded data" row) records the rule and the count. ### Tested No game files in the test. Windows 11, CPU only for the suite. - New `tests/semantic/test_reanchor_dot4_inline_sel.py`, hand-built encodings: - the exact path now translates the form, with the same result as the clean-listing path; - that result is the stored op_sel_hi, not the printed one; - a register-S1 mismatch is still refused. - Before the fix, the first two fail with the error above. - `python -I scripts/run_semantic_tests.py tests/semantic`: 488 files, 6,282 tests, 0 failed (292 s, 16 jobs). - Counted on my own 1.0.2.1 copy (LLVM 21.1.8, `--wave64-emulate`), the FidelityFX DLL's 29 programs: - `main`: 22 translated; - this PR: 24; - this PR with #674 (SHADER-VCC-TUPLE-RESYNC) on top: **29 of 29**, all pass `spirv-val`; - #674 alone: 28. - So the two PRs are independent, and both are needed for the whole DLL. - Retail boot with all 29 programs (RTX 4070 SUPER, NVIDIA 621.01; `LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WATCHDOG=0`, plus #1631): the upscaler crash that ended the runs before is gone, and the run lasted its full 485 s. A device loss on a library compute dispatch came late in the run. That's a separate matter. AI-assisted (Claude Code). GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (retail boot only; the translator tests need no GPU) AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:22:04 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1677
No description provided.