Shaders: combine consecutive constant AND masks #3734
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3734"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:07:06Z.
Combine two consecutive 32-bit ANDs with constant masks as
(x & a) & b → x & (a & b), with either operand order. Other readers can still use the intermediate value. Existing liveness drops it when there are no readers. LLVM integer AND.Microsoft WARP 1.0.22 with Agility 1.620.2 matched the integer reference and reproduced the same 6,174 output words on both builds. The committed test verifies the combined mask, either operand order, and liveness of a shared intermediate. All 13 bitcode tests passed, with the existing benchmark ignored. Strict all-feature shader Clippy and the asset policy passed. The counts and sizes are from emitted DXIL. Game performance was unmeasured.
#1646 and #1716 cover constant operands and identity operations. This fold handles a live input flowing through a chain of constant masks.
Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:11:17Z.
Windows CI passed on
e61d843, including the workspace tests and both Clippy configurations. The combined run with #1716 matched all WARP outputs and confirmed the same 11-instruction reduction in the 12-mask fixture. Combined result.The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T13:23:39Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
e61d8432a0fde173b4c398829fe0c0ead0f01f4a, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::consecutive_constant_and_masks_share_the_original_value --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the base returned no match (test is new on this PR);git diff --check 63bcca4 HEADclean (1 file, +56/-0).CARGO_TARGET_DIR(never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.