[PR #2362] rdna2spirv: forward DPP src0 neg/abs to op readers instead of eager 32-bit modify (SHADER-DPP-F16-AND-SIGN-MODS) #2365

Open
opened 2026-11-26 21:20:59 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2362
Author: @ShotTechOp
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/dpp-f16-and-sign-mods


📝 Commits (1)

  • cf622ce rdna2spirv: forward DPP src0 neg/abs to op readers instead of eager 32-bit modify (SHADER-DPP-F16-AND-SIGN-MODS)

📊 Changes

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

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_dpp_f16_mods.py (+188 -0)
📝 tools/rdna2spirv.py (+4 -1)

📄 Description

Item ID: SHADER-DPP-F16-AND-SIGN-MODS

Summary

Fixes Gen.dpp_insn() in tools/rdna2spirv.py so src0's neg/abs modifiers are forwarded on the post-select ssa operand instead of eagerly applying 32-bit float Gen.modify(src0, src) (bit 31 FAbs/OpFNegate) before dispatching to _insn():

  1. All 16-bit float DPP ops (v_add_f16_dpp, v_sub_f16_dpp, v_subrev_f16_dpp, v_mul_f16_dpp, v_min_f16_dpp, v_max_f16_dpp, v_fmac_f16_dpp, v_cvt_f32_f16_dpp, v_cmp_*_f16_dpp, etc.): previously Gen.modify() cleared/flipped bit 31 (the unused high half) and stripped neg/abs, so -v1 and |v1| were completely ignored on the f16 low half (bit 15), and bound_ctrl:1 with -v1 produced +0.0h instead of -0.0h. Forwarding neg/abs lets f16_in / f16_in_bits / modify_f / cmp_class apply them to bit 15 after the invalid-lane zero select.
  2. Sign-bit-move / sNaN-preserving f32 DPP ops (v_cndmask_b32_dpp, v_min_f32_dpp, v_max_f32_dpp, v_cmp_class_f32_dpp): previously eager Gen.modify() emitted FAbs/OpFNegate (which can quiet sNaNs and flush denormals) before those ops ran their raw integer bit-31 sign-move paths (src_u_sign_mods / src_f_sign_mods / cmp_class).
  3. Preserves HW-DPP-NEG-INVALID-LANE (test_dpp_bound_ctrl_modifiers.py): modifiers still apply after OpSelect %uint %src_ok %shuffled %c0, so v_mov_b32_dpp v2, -v1 ... bound_ctrl:1 still produces -0.0f (0x80000000) with OpBitcast %float + FAbs/OpFNegate on the select result.

Updates the DPP contract row in docs/design.md and adds tests/semantic/test_dpp_f16_mods.py.

Verification

  • AI-assisted: yes
  • Environment: Windows 11, Python 3.12.10 (CPU semantic interpreter spirv_mini_interp & spirv_wave_interp; no local GPU/Vulkan/spirv-val installed)
  • GREEN checks:
    • python -I tests/semantic/test_dpp_f16_mods.py -v -> 4/4 OK (wave32 & --wave64-emulate)
    • python -I tests/semantic/test_dpp_bound_ctrl_modifiers.py -> 2/2 OK
    • python -I tests/semantic/test_dpp_compare.py -> 9/9 OK (2 skipped)
    • python -I tests/semantic/test_dpp_eager_subgroup.py -> 8/8 OK
    • python -I tests/test_text_write_line_endings.py -> 3/3 OK
    • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py -> exit 0
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py docs/design.md -> exit 0
    • git diff --check -> clean
  • RED control against origin/main (tools/ extracted from origin/main):
    • tests/semantic/test_dpp_f16_mods.py fails 4/4 tests (v_add_f16_dpp/v_mul_f16_dpp ignore f16 -/| |, v_cvt_f32_f16_dpp yields +0.0f instead of -0.0f, v_min_f16_dpp yields +1.0h instead of -3.0h, and v_cndmask_b32_dpp/v_cmp_class_f32_dpp emit OpFNegate).

🔄 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/2362 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/dpp-f16-and-sign-mods` --- ### 📝 Commits (1) - [`cf622ce`](https://github.com/ubiquitarianism/leonida/commit/cf622ce9c2413b0302d4af282cb1bf5fa73b0980) rdna2spirv: forward DPP src0 neg/abs to op readers instead of eager 32-bit modify (SHADER-DPP-F16-AND-SIGN-MODS) ### 📊 Changes **3 files changed** (+193 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_dpp_f16_mods.py` (+188 -0) 📝 `tools/rdna2spirv.py` (+4 -1) </details> ### 📄 Description Item ID: `SHADER-DPP-F16-AND-SIGN-MODS` ## Summary Fixes `Gen.dpp_insn()` in `tools/rdna2spirv.py` so `src0`'s `neg`/`abs` modifiers are forwarded on the post-select `ssa` operand instead of eagerly applying 32-bit float `Gen.modify(src0, src)` (bit 31 `FAbs`/`OpFNegate`) before dispatching to `_insn()`: 1. **All 16-bit float DPP ops (`v_add_f16_dpp`, `v_sub_f16_dpp`, `v_subrev_f16_dpp`, `v_mul_f16_dpp`, `v_min_f16_dpp`, `v_max_f16_dpp`, `v_fmac_f16_dpp`, `v_cvt_f32_f16_dpp`, `v_cmp_*_f16_dpp`, etc.)**: previously `Gen.modify()` cleared/flipped **bit 31** (the unused high half) and stripped `neg`/`abs`, so `-v1` and `|v1|` were completely ignored on the f16 low half (bit 15), and `bound_ctrl:1` with `-v1` produced `+0.0h` instead of `-0.0h`. Forwarding `neg`/`abs` lets `f16_in` / `f16_in_bits` / `modify_f` / `cmp_class` apply them to bit 15 after the invalid-lane zero select. 2. **Sign-bit-move / sNaN-preserving f32 DPP ops (`v_cndmask_b32_dpp`, `v_min_f32_dpp`, `v_max_f32_dpp`, `v_cmp_class_f32_dpp`)**: previously eager `Gen.modify()` emitted `FAbs`/`OpFNegate` (which can quiet sNaNs and flush denormals) before those ops ran their raw integer bit-31 sign-move paths (`src_u_sign_mods` / `src_f_sign_mods` / `cmp_class`). 3. **Preserves `HW-DPP-NEG-INVALID-LANE` (`test_dpp_bound_ctrl_modifiers.py`)**: modifiers still apply **after** `OpSelect %uint %src_ok %shuffled %c0`, so `v_mov_b32_dpp v2, -v1 ... bound_ctrl:1` still produces `-0.0f` (`0x80000000`) with `OpBitcast %float` + `FAbs`/`OpFNegate` on the select result. Updates the DPP contract row in `docs/design.md` and adds `tests/semantic/test_dpp_f16_mods.py`. ## Verification - **AI-assisted**: yes - **Environment**: Windows 11, Python 3.12.10 (CPU semantic interpreter `spirv_mini_interp` & `spirv_wave_interp`; no local GPU/Vulkan/`spirv-val` installed) - **GREEN checks**: - `python -I tests/semantic/test_dpp_f16_mods.py -v` -> 4/4 OK (wave32 & `--wave64-emulate`) - `python -I tests/semantic/test_dpp_bound_ctrl_modifiers.py` -> 2/2 OK - `python -I tests/semantic/test_dpp_compare.py` -> 9/9 OK (2 skipped) - `python -I tests/semantic/test_dpp_eager_subgroup.py` -> 8/8 OK - `python -I tests/test_text_write_line_endings.py` -> 3/3 OK - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py docs/design.md` -> exit 0 - `git diff --check` -> clean - **RED control against `origin/main` (`tools/` extracted from `origin/main`)**: - `tests/semantic/test_dpp_f16_mods.py` fails 4/4 tests (`v_add_f16_dpp`/`v_mul_f16_dpp` ignore f16 `-`/`| |`, `v_cvt_f32_f16_dpp` yields `+0.0f` instead of `-0.0f`, `v_min_f16_dpp` yields `+1.0h` instead of `-3.0h`, and `v_cndmask_b32_dpp`/`v_cmp_class_f32_dpp` emit `OpFNegate`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#2365
No description provided.