shader: expand constant dot4 multiplicands to avoid Arc IGC miscompilation #2536

Open
github-bot wants to merge 1 commit from github-bot/gh-2536 into main AGit
Owner

@⁠UnkwnDev on GitHub · 2026-11-25 15:26 UTC · original
UnkwnDev:arc-dot4-constant-fix → main · +230 −18 · 3 files · 1 commits · open

Fixes \ spx_programs_run_with_the_hardwares_dot_products\ (and equivalent \ _dot4_i32_i8\ / \ _dot4c_i32_i8\ sequences) failing on Intel Arc A770 hardware while passing on WARP.

Root Cause

When a packed byte dot-product multiplicand evaluates at DXIL compile time to a 16-bit constant (such as the FidelityFX \sel_hi_lo(2.0)\ operand \

**@⁠UnkwnDev** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2536) `UnkwnDev:arc-dot4-constant-fix` → `main` · +230 −18 · 3 files · 1 commits · open Fixes \ spx_programs_run_with_the_hardwares_dot_products\ (and equivalent \ _dot4_i32_i8\ / \ _dot4c_i32_i8\ sequences) failing on Intel Arc A770 hardware while passing on WARP. ## Root Cause When a packed byte dot-product multiplicand evaluates at DXIL compile time to a 16-bit constant (such as the FidelityFX \sel_hi_lo(2.0)\ operand \
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:32 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:55 UTC · original · edited 2026-11-25 20:22 UTC

Automated triage for the maintainers.

Proposed close: duplicate of #2408. This PR's head (a3a18d6) has not changed since the last review. #2408 (open, merges cleanly, CI passing) makes the same change in crates/victory-shader/src/emit/lower.rs. A new dot4_i8 expands a constant multiplicand over its non-zero bytes instead of passing it to dot4AddPacked.i32, and it is backed by a constant evaluator in emit/bitcode.rs (known_i32 there, eval_u32 here). #2408 also cites the driver evidence this PR lacked (#1829, #1896) and has the larger test suite.

Reply to the author: thanks for comparing the two. We agree that #2408 is the one to land. The _dot4_u32_u8 extension you mention fits better in #2202 once that is rebased on #2408, so nothing here needs to stay open for it.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.

CI: check passed (Windows).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7167435024) · edited 2026-11-25 20:22 UTC <!-- victory-triage v1 head=a3a18d63b5beb45c962afe94cc67a7e0cf3778b1 verdict=proposed-close at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Proposed close: duplicate of #2408.** This PR's head (`a3a18d6`) has not changed since the last review. #2408 (open, merges cleanly, CI passing) makes the same change in `crates/victory-shader/src/emit/lower.rs`. A new `dot4_i8` expands a constant multiplicand over its non-zero bytes instead of passing it to `dot4AddPacked.i32`, and it is backed by a constant evaluator in `emit/bitcode.rs` (`known_i32` there, `eval_u32` here). #2408 also cites the driver evidence this PR lacked (#1829, #1896) and has the larger test suite. **Reply to the author:** thanks for comparing the two. We agree that #2408 is the one to land. The `_dot4_u32_u8` extension you mention fits better in #2202 once that is rebased on #2408, so nothing here needs to stay open for it. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. CI: `check` passed (Windows). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 16:35 UTC · original

#2408 (KainanP, 2644bbc, open; the triage calls it a merge candidate) makes the same change: dot4_i8 takes a constant multiplicand by hand over its non-zero bytes instead of passing it to dot4AddPacked.i32, with a constant evaluator added to emit/bitcode.rs (about 100 lines in both). Its description also cites the driver evidence the triage asks for here: #1829 (Intel Xe-LP reads a constant dot4AddPacked operand that fits in 16 bits as its low half in both halves) and #1896 (the RTX 5070 does the same for 0x4000). It may be simplest to compare the two before either goes further.

AI-assisted (Claude Code, Claude Opus 5.5). Compared the two diffs only; nothing run.

**@⁠upipibi** on GitHub · 2026-11-25 16:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7168236596) #2408 (KainanP, `2644bbc`, open; the triage calls it a merge candidate) makes the same change: `dot4_i8` takes a constant multiplicand by hand over its non-zero bytes instead of passing it to `dot4AddPacked.i32`, with a constant evaluator added to `emit/bitcode.rs` (about 100 lines in both). Its description also cites the driver evidence the triage asks for here: #1829 (Intel Xe-LP reads a constant `dot4AddPacked` operand that fits in 16 bits as its low half in both halves) and #1896 (the RTX 5070 does the same for 0x4000). It may be simplest to compare the two before either goes further. AI-assisted (Claude Code, Claude Opus 5.5). Compared the two diffs only; nothing run.
Author
Owner

@⁠UnkwnDev on GitHub · 2026-11-25 17:16 UTC · original

@⁠upipibi Thanks for the pointer.

I compared the two diffs:

  1. Both patches target the same underlying driver behavior (#1829 / #1896), where Intel Xe-LP/Arc IGC and NVIDIA drivers encode constant multiplicands in 16 bits and replicate them into both halves inside dot4AddPacked.
  2. KainanP's #2408 provides a thorough evaluator (known_i32 in emit/bitcode.rs) covering binary ops, casts, and selects, accompanied by the dot4_takes_every_constant_class_whole test suite for _dot4_i32_i8 and _dot4c_i32_i8.
  3. Our branch was developed alongside the broader packed dot products lowering (#2202), which also adds _dot4_u32_u8 (where unsigned constant operands into dot4AddPacked.u32 require the same scalar expansion), as well as dot2 and dot8.

Since #2408 is already designated a merge candidate by the triage for main, landing #2408 first is the cleaner approach. Once #2408 is merged into main, we can close #2536 as superseded and rebase #2202 on top of #2408's known_i32 foundation to extend constant expansion to _dot4_u32_u8.

**@⁠UnkwnDev** on GitHub · 2026-11-25 17:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7169273588) @⁠upipibi Thanks for the pointer. I compared the two diffs: 1. Both patches target the same underlying driver behavior (#1829 / #1896), where Intel Xe-LP/Arc IGC and NVIDIA drivers encode constant multiplicands in 16 bits and replicate them into both halves inside dot4AddPacked. 2. KainanP's #2408 provides a thorough evaluator (known_i32 in emit/bitcode.rs) covering binary ops, casts, and selects, accompanied by the dot4_takes_every_constant_class_whole test suite for _dot4_i32_i8 and _dot4c_i32_i8. 3. Our branch was developed alongside the broader packed dot products lowering (#2202), which also adds _dot4_u32_u8 (where unsigned constant operands into dot4AddPacked.u32 require the same scalar expansion), as well as dot2 and dot8. Since #2408 is already designated a merge candidate by the triage for main, landing #2408 first is the cleaner approach. Once #2408 is merged into main, we can close #2536 as superseded and rebase #2202 on top of #2408's known_i32 foundation to extend constant expansion to _dot4_u32_u8.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/bitcode.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2536/head:github-bot/gh-2536'
git switch 'github-bot/gh-2536'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2536'
git switch 'github-bot/gh-2536'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2536'
git switch 'github-bot/gh-2536'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2536'
git switch 'main'
git merge --squash 'github-bot/gh-2536'
git switch 'main'
git merge --ff-only 'github-bot/gh-2536'
git switch 'main'
git merge 'github-bot/gh-2536'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/Marvisak--VIctory!2536
No description provided.