shader: refuse reads of the carry s_lshlN_add_u32 leaves in SCC #2811

Open
spy0eye-beep wants to merge 1 commit from upstream-pr/2813 into main
spy0eye-beep commented 2026-11-25 21:14:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by spy0eye-beep on 2026-11-25T21:14:40Z.


Split out of #1483 as requested in review. The s_min/s_max part of that PR is already fixed on main; this is the remaining piece.

s_lshl{1..4}_add_u32 fell through to the default SCC = (result != 0), but the hardware sets the add's carry. Like s_add/s_sub, SCC is now marked unknown, so a shader that reads it is refused instead of silently mistranslated.

Test: lshl_add_carry_read_is_refused builds each of the four ops followed by s_cselect_b32 on SCC and expects the refusal (it fails without the change). cargo test -p victory-shader: the same 9 tests fail on main and on this branch.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6613890859 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2813). Originally posted by [spy0eye-beep](https://github.com/spy0eye-beep) on 2026-11-25T21:14:40Z. --- Split out of #1483 as requested in review. The s_min/s_max part of that PR is already fixed on main; this is the remaining piece. `s_lshl{1..4}_add_u32` fell through to the default SCC = (result != 0), but the hardware sets the add's carry. Like s_add/s_sub, SCC is now marked unknown, so a shader that reads it is refused instead of silently mistranslated. Test: `lshl_add_carry_read_is_refused` builds each of the four ops followed by `s_cselect_b32` on SCC and expects the refusal (it fails without the change). `cargo test -p victory-shader`: the same 9 tests fail on main and on this branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kotekompotek commented 2026-11-25 22:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:19:06Z.

Review: COMMENTED


Correct per ISA: s_lshl1-4_add_u32 set SCC to the add's carry-out, not result != 0 — reading it through the generic SCC path silently produced the wrong predicate. Refusing it alongside the add/sub carries is the honest behavior until carry tracking lands. The pattern is precise (s_lshl prefix AND _add_u32 suffix, so plain s_lshl_b32 shifts still fall through), and the test covers all four ops 0x2e-0x31 reading SCC via s_cselect. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065127121 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2813#pullrequestreview-6065127121). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:19:06Z. **Review:** COMMENTED --- Correct per ISA: `s_lshl1-4_add_u32` set SCC to the add's carry-out, not `result != 0` — reading it through the generic SCC path silently produced the wrong predicate. Refusing it alongside the add/sub carries is the honest behavior until carry tracking lands. The pattern is precise (`s_lshl` prefix AND `_add_u32` suffix, so plain `s_lshl_b32` shifts still fall through), and the test covers all four ops 0x2e-0x31 reading SCC via `s_cselect`. LGTM.
fuzeofficlal commented 2026-11-25 22:04:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:30:47Z.


Verified 0e193dbd on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll):

  • cargo xtask policy: 184 files ok.
  • RTX 5090 (lshl_add_carry_read_is_refused + carries_match_the_hardware): 2/2 passed; WARP + dxil.dll: 268 passed, 0 failed.
  • Logic looks spot-on: name.starts_with("s_lshl") && name.ends_with("_add_u32") targets s_lshl1_add_u32..s_lshl4_add_u32 without affecting s_lshl_b32/_b64, and merges cleanly with #2385.

One clippy failure causing CI to fail:

  • crates/victory-shader/src/emit/valu_tests.rs:1821:43: error: called '.err().expect()' on a Result value (-D clippy::err_expect). Replacing refused.err().expect("refused") with refused.expect_err("refused") will clear CI.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175175567 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2813#issuecomment-7175175567). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:30:47Z. --- Verified `0e193dbd` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`): - `cargo xtask policy`: 184 files ok. - RTX 5090 (`lshl_add_carry_read_is_refused` + `carries_match_the_hardware`): 2/2 passed; WARP + `dxil.dll`: 268 passed, 0 failed. - Logic looks spot-on: `name.starts_with("s_lshl") && name.ends_with("_add_u32")` targets `s_lshl1_add_u32`..`s_lshl4_add_u32` without affecting `s_lshl_b32`/`_b64`, and merges cleanly with #2385. One clippy failure causing CI to fail: - `crates/victory-shader/src/emit/valu_tests.rs:1821:43`: `error: called '.err().expect()' on a Result value` (`-D clippy::err_expect`). Replacing `refused.err().expect("refused")` with `refused.expect_err("refused")` will clear CI.
Marvisak commented 2026-11-26 00:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:14:37Z.


Automated triage for the maintainers.

This PR no longer merges cleanly into main: it conflicts in crates/victory-shader/src/emit/valu_tests.rs. Its content will be reviewed once it is rebased onto current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177305982 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2813#issuecomment-7177305982). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:14:37Z. --- <!-- victory-triage v1 head=0e193dbd9d1b78c9b3c9b463bcb73d9d81647dd1 verdict=needs-rebase at=2026-11-25T23:13:52Z --> Automated triage for the maintainers. This PR no longer merges cleanly into `main`: it conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. Its content will be reviewed once it is rebased onto current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2813:upstream-pr/2813'
git switch 'upstream-pr/2813'

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/2813'
git switch 'upstream-pr/2813'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2813'
git switch 'upstream-pr/2813'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2813'
git switch 'main'
git merge --squash 'upstream-pr/2813'
git switch 'main'
git merge --ff-only 'upstream-pr/2813'
git switch 'main'
git merge 'upstream-pr/2813'
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!2811
No description provided.