Skip to content

Shaders: reuse the predicate when reading a zero-extended SCC - #1546

Draft
Roroca-1 wants to merge 2 commits into
xcl-dev:mainfrom
Roroca-1:dxil-opt-3-instcombine-cse
Draft

Roroca-1 wants to merge 2 commits into
xcl-dev:mainfrom
Roroca-1:dxil-opt-3-instcombine-cse

Conversation

@Roroca-1

@Roroca-1 Roroca-1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Stacked on #1544. Only ce8c103 belongs here. Part of #1269.

Direct lowering writes the scalar condition code (SCC) by zero-extending an i1 predicate to i32. Reading SCC tests that word against zero. The comparison can return the original predicate.

What is in it

Tested

  • Ryzen 7 7800X3D, Linux x86-64, Rust 1.98.1, Windows MSVC debug target via cargo-xwin. CPU-side tests under Wine on clean ce8c103.
  • TARGET_CFLAGS=/FIstring.h cargo xwin build --tests -p xcl --target x86_64-pc-windows-msvc succeeded.
  • wine xcl-67594ede252ac8b9.exe gpu::dxil::module::tests --nocapture ran 2 passed, 0 failed, 0 ignored, 0 skipped. Before the fold, the SCC test observed a new instruction instead of the original predicate and failed.
  • wine xcl-67594ede252ac8b9.exe gpu::dxil::bitreader_tests --test-threads=4 ran 3 passed, 0 failed, 0 ignored, 0 skipped.
  • For the earlier sibling-scope review, a temporary diamond test exercised the unchanged upstream optimizer. The join PHI kept each arm’s local value and the duplicate in one arm folded (1 passed, 0 failed, 0 ignored, 0 skipped).

Regression run
Pending paired clean main/head retail-title runs.

Not tested
Native Windows GPU workspace suite, DXIL validation, retail shaders and performance.

AI use
T3 Code (Codex, gpt-6.2-astra) narrowed the original T3 Code (Antigravity, gemini-pro-orchestrator-neon) optimizer proposal, wrote the current patch and tests, and ran the Wine checks.

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

AI-assisted review (GPT-6): I traced the dominator traversal and CSE table lifetime in the current diff.

Comment thread crates/xcl/src/gpu/dxil/opt.rs Resolved
An unreachable conversion survives in the instruction arena after optimization. Scan block instructions when inferring flags and invalidate cached containers.
The direct lowering stores SCC as an i32 zero extension and tests it against zero. Reuse the i1 instruction for this exact round trip and invalidate older cached containers.
@Roroca-1
Roroca-1 force-pushed the dxil-opt-3-instcombine-cse branch from f3ee243 to ce8c103 Compare November 24, 2026 19:18
@Roroca-1 Roroca-1 changed the title Shaders: add DXIL InstCombine constant folding and dominator CSE Shaders: reuse the predicate when reading a zero-extended SCC Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of ce8c1039 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: ce8c103945a6965450946d89c071e152dae5881b
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ce8c103

Stacked on #1544; only ce8c103 belongs here. The base commit of #1544 is already on main (#3266, 4a20b25), so after a rebase this PR is just the SCC fold in dxil/module.rs:cmp and its test. No other open PR folds cmp(Ne, zext(i1), 0).
The TRANSLATOR_VERSION bump to 6 is behind main (12); on rebase it needs to move past main's value.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants