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

Open
UnkwnDev wants to merge 1 commit from upstream-pr/2536 into main
UnkwnDev commented 2026-11-25 15:26:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by UnkwnDev on 2026-11-25T15:26:48Z.


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 \

<!-- greyfinch-sync:Marvisak/VIctory:issue:6607930813 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2536). Originally posted by [UnkwnDev](https://github.com/UnkwnDev) on 2026-11-25T15:26:48Z. --- 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 \
Marvisak commented 2026-11-25 16:09:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:55:33Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167435024 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7167435024). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:55:33Z. --- <!-- 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)_
upipibi commented 2026-11-25 17:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T16:35:56Z.


#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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168236596 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7168236596). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T16:35:56Z. --- #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.
UnkwnDev commented 2026-11-25 18:02:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by UnkwnDev on 2026-11-25T17:16:57Z.


@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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169273588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2536#issuecomment-7169273588). Originally posted by [UnkwnDev](https://github.com/UnkwnDev) on 2026-11-25T17:16:57Z. --- @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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2536:upstream-pr/2536'
git switch 'upstream-pr/2536'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2536'
git switch 'upstream-pr/2536'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2536'
git switch 'upstream-pr/2536'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2536'
git switch 'main'
git merge --squash 'upstream-pr/2536'
git switch 'main'
git merge --ff-only 'upstream-pr/2536'
git switch 'main'
git merge 'upstream-pr/2536'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2534
No description provided.