Shaders: lower v_cmp_{f,t}_{i64,u64} constant 64-bit compares #1684

Open
Calvix2k wants to merge 1 commit from upstream-pr/1685 into main
Calvix2k commented 2026-11-24 20:44:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T20:44:42Z.


Implements #1531.

Ports the fix from @davi713albano-coder's fork (commit 41715fc by Davi713), applied unchanged onto ffe310e; the commit keeps its original author.

Summary

The u64 | i64 arm of emit::lower::compare fell through to Err("a 64-bit compare") for the constant-true and constant-false compares, while the 32-bit arm handled them with self.lane(inst, Some(op == "t")).

  • v_cmp_{f,t}_{i64,u64} and v_cmpx_{f,t}_{i64,u64} now short-circuit before src64, so a constant compare does not set the Int64 flag (SFI0 bit 0x8000) it does not need.

Test

New synthetic compute test v_cmp_f_and_t_64bit_match_rdna2 covers v_cmp_f_i64, v_cmp_t_i64, v_cmp_f_u64 and v_cmp_t_u64: dxil.dll validation, absence of the Int64 flag, and execution on D3D12 hardware/WARP.

Validation

  • cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests — passed (102 tests, 1 ignored).
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings — passed.
  • cargo xtask policy — passed (154 files).
  • Upstream fork CI ran the full workspace, including the new WARP/hardware VALU test: 343 passed, 0 failed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5480026328 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T20:44:42Z. --- Implements #1531. Ports the fix from [@davi713albano-coder's fork](https://github.com/Marvisak/VIctory/compare/main...davi713albano-coder:VIctory:shader/cmp64-f-and-t) (commit 41715fc by Davi713), applied unchanged onto `ffe310e`; the commit keeps its original author. ## Summary The `u64 | i64` arm of `emit::lower::compare` fell through to `Err("a 64-bit compare")` for the constant-true and constant-false compares, while the 32-bit arm handled them with `self.lane(inst, Some(op == "t"))`. - `v_cmp_{f,t}_{i64,u64}` and `v_cmpx_{f,t}_{i64,u64}` now short-circuit before `src64`, so a constant compare does not set the `Int64` flag (`SFI0` bit 0x8000) it does not need. ## Test New synthetic compute test `v_cmp_f_and_t_64bit_match_rdna2` covers `v_cmp_f_i64`, `v_cmp_t_i64`, `v_cmp_f_u64` and `v_cmp_t_u64`: dxil.dll validation, absence of the `Int64` flag, and execution on D3D12 hardware/WARP. ## Validation - `cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests` — passed (102 tests, 1 ignored). - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` — passed. - `cargo xtask policy` — passed (154 files). - Upstream fork CI ran the full workspace, including the new WARP/hardware VALU test: 343 passed, 0 failed.
catminou4 commented 2026-11-24 21:40:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:10Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

v_cmp_f_i64/v_cmp_t_i64/v_cmp_f_u64/v_cmp_t_u64 constant 64-bit compares: 59-line diff with an RDNA2 reference test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047849310 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#pullrequestreview-6047849310). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:40:10Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. v_cmp_f_i64/v_cmp_t_i64/v_cmp_f_u64/v_cmp_t_u64 constant 64-bit compares: 59-line diff with an RDNA2 reference test.
Calvix2k commented 2026-11-24 22:02:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:40:05Z.


Hardware run on the RX 7800 XT (RDNA3), Windows 10 x64, Agility SDK 1.616 for SM 6.6:

  • cargo test -p victory-shader --locked v_cmp_f_and_t_64bit_match_rdna2 -- --test-threads=1 --nocapture — 1 passed, 0 failed on the hardware backend.
  • WARP skipped (SM 6.2 here), so this confirms the constant-true/false 64-bit compares and the absent Int64 flag on AMD hardware.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7145232087 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7145232087). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:40:05Z. --- Hardware run on the RX 7800 XT (RDNA3), Windows 10 x64, Agility SDK 1.616 for SM 6.6: - `cargo test -p victory-shader --locked v_cmp_f_and_t_64bit_match_rdna2 -- --test-threads=1 --nocapture` — **1 passed, 0 failed** on the hardware backend. - WARP skipped (SM 6.2 here), so this confirms the constant-true/false 64-bit compares and the absent `Int64` flag on AMD hardware.
Calvix2k commented 2026-11-24 23:05:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:14:11Z.


Rebased onto 70564ae; only the test module conflicted (upstream added more test helpers). Both sets are kept. cargo check -p victory-shader --tests --locked passes; the test itself was already verified on a Radeon RX 7800 XT before the rebase and is unchanged.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145976586 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7145976586). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T22:14:11Z. --- Rebased onto 70564ae; only the test module conflicted (upstream added more test helpers). Both sets are kept. cargo check -p victory-shader --tests --locked passes; the test itself was already verified on a Radeon RX 7800 XT before the rebase and is unchanged.
upipibi commented 2026-11-24 23:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:51:59Z.


NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, d7536bd (on main 70564ae). v_cmp_f_and_t_64bit_match_rdna2 passes on the hardware adapter.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146735224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7146735224). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:51:59Z. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `d7536bd` (on `main` `70564ae`). `v_cmp_f_and_t_64bit_match_rdna2` passes on the hardware adapter. AI-assisted (Claude Code). Synthetic tests only.
Marvisak commented 2026-11-25 04:06:57 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/lower.rs and crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152025268 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7152025268). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:33:28Z. --- <!-- victory-triage v1 head=d8693330ef982db141f23297818bb784c9bff0e1 verdict=needs-rebase at=2026-11-25T22:28:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/lower.rs` and `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
StExpeditus commented 2026-11-25 05:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T04:23:48Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at d869333. cargo test --workspace --locked --no-fail-fast -> all green: 0 passed, 0 ignored, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152804188 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7152804188). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T04:23:48Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `d869333`. `cargo test --workspace --locked --no-fail-fast` -> **all green**: 0 passed, 0 ignored, 0 failed.
StExpeditus commented 2026-11-25 09:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:06:01Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at d869333. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157873623 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7157873623). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:06:01Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `d869333`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
Calvix2k commented 2026-11-25 11:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T10:14:53Z.


Hardware run on an RX 7800 XT (RDNA3), Windows 10 19045, SM 6.6 via the Agility runtime for the test binaries (#486): victory-shader lib suite 248 passed, 0 failed, 3 ignored, including the 64-bit constant-compare cases. The lowering is exercised on the card here as well as on CI's device.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159433468 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7159433468). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T10:14:53Z. --- Hardware run on an **RX 7800 XT (RDNA3), Windows 10 19045**, SM 6.6 via the Agility runtime for the test binaries (#486): `victory-shader` lib suite **248 passed, 0 failed, 3 ignored**, including the 64-bit constant-compare cases. The lowering is exercised on the card here as well as on CI's device.
Calvix2k commented 2026-11-26 14:01:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-26T13:53:16Z.


Rebased. The f/t early return now runs before upstream's dword-wise comparison, so both the AMD dword order and the float predicates are handled by one path.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193974809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7193974809). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-26T13:53:16Z. --- Rebased. The `f`/`t` early return now runs before upstream's dword-wise comparison, so both the AMD dword order and the float predicates are handled by one path.
andrewpozdnakov7-jpg commented 2026-11-27 12:05:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T12:05:41Z.


I checked 803c7f3 on Windows with WARP 1.0.22 and DXIL validation. The existing four v_cmp cases pass. 189e553 adds a test directly on this head for constant signed and unsigned v_cmpx, both true and false.

It uses two operand sets for each opcode, with the lane initially active and inactive. A write between the compare and restoring EXEC verifies which lanes ran, and the emitted SFI0 Int64 bit is clear in all eight shaders. With both fixtures on 63bcca4, they fail during lowering with a 64-bit compare. On the test branch both pass, and the full VALU group is 37/37. Strict all-targets/all-features shader Clippy and asset policy passed.

If you take the test, please keep its Git author. If folding it in, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic WARP testing only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7217832222 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1685#issuecomment-7217832222). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T12:05:41Z. --- I checked `803c7f3` on Windows with WARP 1.0.22 and DXIL validation. The existing four `v_cmp` cases pass. [189e553](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/189e5537d1a4d7a468461f5a9bca8de996fe0524) adds a test directly on this head for constant signed and unsigned `v_cmpx`, both true and false. It uses two operand sets for each opcode, with the lane initially active and inactive. A write between the compare and restoring EXEC verifies which lanes ran, and the emitted `SFI0` Int64 bit is clear in all eight shaders. With both fixtures on `63bcca4`, they fail during lowering with `a 64-bit compare`. On the test branch both pass, and the full VALU group is 37/37. Strict all-targets/all-features shader Clippy and asset policy passed. If you take the test, please keep its Git author. If folding it in, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic WARP testing only.
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/1685:upstream-pr/1685'
git switch 'upstream-pr/1685'

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