[PR #1287] [MERGED] rdna2spirv: flush literal MAD denormals (SHADER-LITERAL-MAD-DENORM) #1317

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1287
Author: @anonymechab-droid
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/literal-mad-denorm


📝 Commits (1)

  • fed33be rdna2spirv: flush literal MAD denormals (SHADER-LITERAL-MAD-DENORM)

📊 Changes

5 files changed (+119 additions, -18 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/fixtures/literal_mad_denorm.asm (+17 -0)
➕ tests/semantic/test_literal_mad_denorm.py (+77 -0)
📝 tests/semantic/test_valu_mad_lit.py (+19 -15)
📝 tools/rdna2spirv.py (+5 -2)

📄 Description

Claimed in the coordination issue as: SHADER-LITERAL-MAD-DENORM — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144562403

Depends on: none.

What and why

Literal MAD currently preserves f32 subnormals, unlike the existing v_mad_f32 lowering and Mesa ACO's documented always-flush rule for v_madak_f32 / v_madmk_f32. For example, the synthetic calculation 0x00000001 * 0x7e800000 + 0 returns 0x34000000 instead of zero.

Flush each operand, the separately rounded product and the final sum with the existing Gen.flush_f32 helper. Keep the literal operand order, separate rounding and destination masking. Add a hand-written fixture and 64 boundary/control combinations across both instructions and their _e32 spellings, plus NaN propagation checks. Update the contract row with the Mesa reference and the limits of the verification.

The existing negative controls now locate the multiply and add independently, preserving the intervening flush chain while still proving that operand swapping and accidental fusion change the result.

Tested

  • Before the fix, the new regression file reports 41 failures (40 boundary subcases plus the fixture); after the fix, all 3 tests pass.
  • python -m unittest discover -s tests/semantic -p test_valu_mad_lit.py: 15 tests passed, including the adapted negative controls.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 12: 472 files, 6,180 tests, 0 files failed in 446 seconds, on the final commit fed33bea.
  • python -m compileall -q make_game.py tools tests: passed.
  • python -I tests/test_semantic_translator_use.py: 3 tests passed.
  • python -I tests/test_docs_links.py: 16 tests passed.
  • python -I tests/test_text_write_line_endings.py: 3 tests passed.
  • python -I make_game.py --help, git diff --check, and scripts/check_no_game_data.py on all five changed files: passed.

Host: Windows, Python 3.14.7. GPUs tested: n/a (CPU interpreter only). No game files were used. Game-corpus translation/validation counts and spirv-val results are not available in this environment; the denormal rule has not been measured on a GPU here.

Upstream GitHub Actions currently reports action_required with no jobs started for CI, No Game Data and Runtime; those remote workflows still need maintainer intervention.

AI-assisted: yes (OpenAI Codex).

Checklist

  • One topic, based on main at 6261ca91; no dependencies.
  • No game data, keys or decryption, including in the examples and fixtures.
  • Contract row updated with its source and CPU verification.
  • Final full translator suite passed.

🔄 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/1287 **Author:** [@anonymechab-droid](https://github.com/anonymechab-droid) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/literal-mad-denorm` --- ### 📝 Commits (1) - [`fed33be`](https://github.com/ubiquitarianism/leonida/commit/fed33beaf5529001eb406b3163bb998053ae18c5) rdna2spirv: flush literal MAD denormals (SHADER-LITERAL-MAD-DENORM) ### 📊 Changes **5 files changed** (+119 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/fixtures/literal_mad_denorm.asm` (+17 -0) ➕ `tests/semantic/test_literal_mad_denorm.py` (+77 -0) 📝 `tests/semantic/test_valu_mad_lit.py` (+19 -15) 📝 `tools/rdna2spirv.py` (+5 -2) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-LITERAL-MAD-DENORM — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144562403 Depends on: none. ### What and why Literal MAD currently preserves f32 subnormals, unlike the existing `v_mad_f32` lowering and Mesa ACO's documented always-flush rule for `v_madak_f32` / `v_madmk_f32`. For example, the synthetic calculation `0x00000001 * 0x7e800000 + 0` returns `0x34000000` instead of zero. Flush each operand, the separately rounded product and the final sum with the existing `Gen.flush_f32` helper. Keep the literal operand order, separate rounding and destination masking. Add a hand-written fixture and 64 boundary/control combinations across both instructions and their `_e32` spellings, plus NaN propagation checks. Update the contract row with the Mesa reference and the limits of the verification. The existing negative controls now locate the multiply and add independently, preserving the intervening flush chain while still proving that operand swapping and accidental fusion change the result. ### Tested - Before the fix, the new regression file reports 41 failures (40 boundary subcases plus the fixture); after the fix, all 3 tests pass. - `python -m unittest discover -s tests/semantic -p test_valu_mad_lit.py`: 15 tests passed, including the adapted negative controls. - `python -I scripts/run_semantic_tests.py tests/semantic -j 12`: 472 files, 6,180 tests, 0 files failed in 446 seconds, on the final commit `fed33bea`. - `python -m compileall -q make_game.py tools tests`: passed. - `python -I tests/test_semantic_translator_use.py`: 3 tests passed. - `python -I tests/test_docs_links.py`: 16 tests passed. - `python -I tests/test_text_write_line_endings.py`: 3 tests passed. - `python -I make_game.py --help`, `git diff --check`, and `scripts/check_no_game_data.py` on all five changed files: passed. Host: Windows, Python 3.14.7. GPUs tested: n/a (CPU interpreter only). No game files were used. Game-corpus translation/validation counts and `spirv-val` results are not available in this environment; the denormal rule has not been measured on a GPU here. Upstream GitHub Actions currently reports `action_required` with no jobs started for CI, No Game Data and Runtime; those remote workflows still need maintainer intervention. AI-assisted: yes (OpenAI Codex). ### Checklist - [x] One topic, based on `main` at `6261ca91`; no dependencies. - [x] No game data, keys or decryption, including in the examples and fixtures. - [x] Contract row updated with its source and CPU verification. - [x] Final full translator suite passed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:50 +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#1317
No description provided.