Skip to content

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

Open
spy0eye-beep wants to merge 1 commit into
Marvisak:mainfrom
spy0eye-beep:fix/lshl-add-scc
Open

spy0eye-beep wants to merge 1 commit into
Marvisak:mainfrom
spy0eye-beep:fix/lshl-add-scc

Conversation

@spy0eye-beep

Copy link
Copy Markdown

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

The default set SCC to result != 0; the hardware sets the add's carry.
Mark it unknown like s_add/s_sub, so a shader reading it is refused
instead of silently mistranslated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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 Shaders: track s_add_u32 with src_scc in address high halves (#815) #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.

JMAN730 added a commit to JMAN730/project-flamingo that referenced this pull request Nov 25, 2026

Copy link
Copy Markdown
Owner

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

Mdemets pushed a commit to Mdemets/project-flamingo that referenced this pull request Nov 26, 2026
The default set SCC to result != 0; the hardware sets the add's carry.
Mark it unknown like s_add/s_sub, so a shader reading it is refused
instead of silently mistranslated.

Ported from Marvisak#2813 (0e193db).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants