dxil: guarded-value demand propagation and algebraic/bitcast folding in opt #1972
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1972
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1972"
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?
@raylitebull on GitHub · 2026-11-25 00:10 UTC · original
raylitebull:feat/dxil-opt-select-guard-prop→main· +588 −63 · 2 files · 1 commits · openAdds guarded-value demand propagation (
propagate_select_guards) and full-EXEC lane-bit folding (and(lshr(-1, s), 1) -> 1) insidecrates/xcl/src/gpu/dxil/module/opt.rsto eliminate redundantselectchains on lowered RDNA shader IR before DXIL serialization.Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/module/opt.rs(+588 / -63acrossopt.rs+graphics_tests.rs, gated byXCL_DXIL_NO_OPT=guard):propagate_select_guards(guard_eligible): propagates boolean/mask guard conditions backward to strictly lane-local, side-effect-free guarded instructions when all observed consumers use a single guarded operand (pre-seedingOp::Phiincoming operands asDemand::Anybefore the reverse-RPO walk, chasing nestedselectreplacements transitively, and restrictingdx.op.*intrinsics inguard_eligibleto a strict lane-local math/bit/conversion allowlistop_code in 6..=42 | 44..=56 | 124..=132so quad derivatives83..=86,Eval*87..=89,Wave*/Quad*, and implicit-LOD texture ops always receiveDemand::Any).known_lt_32& full-EXEC lane-bit fold (and(lshr(-1, s), 1) -> 1) insiderun_cse_simplify, while preservinglocal.clear()acrossdx.op.discardfor wave/quad operations.gpu::dxil::module::opt::tests):block_cse_invalidates_wave_and_quad_calls_across_discard,guard_demand_eliminates_chained_select_and_bitcast,loop_header_phi_preserves_latch_select_guard,full_exec_lanebit_folds_to_true,guarded_derivatives_and_cross_lane_ops_preserve_select_operands, andoptimized_valu_chain_validates_with_dxil.crates/xcl/src/gpu/dxil/graphics_tests.rs: addguarded_derivatives_read_neighbor_values(DXIL validation + disassembly check + fullscreen 8x8 quad-derivative draw test).simplify_oprules so this PR stays orthogonal to #1906, and relies on #1947XCL_DIRECT_DXIL_SOURCE_IDinstead of a manualTRANSLATOR_VERSIONbump.)Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), DXCdxcompiler 1.8.2502.11/dxil 1.8.2502.11, rebased cleanly onto13c2a405(528ca109).cargo check --workspace --tests: passed (0warnings in touched files).cargo test -p xcl --lib gpu::dxil::module::opt::tests: 11 passed, 0 failed (dxil 1.8.2502.11validated, including#2194simplify_cfgtests andguarded_derivatives_and_cross_lane_ops_preserve_select_operands).528ca109:@thehollowedone(NVIDIA RTX 3080 Ti):guarded_derivatives_read_neighbor_valuespassed (0skips) + workspace suite onmain(1,271 passed, 0 failed, 46 ignored).@anes66: CPU quad-derivative IR check (12 passed, 0 failed,2,560output words verified).@Toons29: AMD Radeon RX 9070 60 sscripts/smoke.ps1pair passed (1630vs1628frames,0device removals,0crashes).Regression run
60 s
scripts/smoke.ps1pair on exact head528ca10vsmain1a0bbe3a(AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release,XCL_NETWORK=0on a retail title), contributed by@Toons29:main:
this PR:
Not tested
guarded_derivatives_read_neighbor_valuesand 60 sscripts/smoke.ps1pair on528ca109, fullcargo test --workspacesuite on528ca109, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.AI use
13c2a405, cross-lane allowlist hardening, and DXIL/draw validation tests; the author reviewed the diff and test output.@futurepro62 on GitHub · 2026-11-25 00:26 UTC · original · edited 2026-11-25 00:43 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
c04f6c6(on its base80f4819).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 985 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.guard_demand_eliminates_chained_select_and_bitcast,full_exec_lanebit_and_zext_cmp_and_const_bitcast_fold,optimized_valu_chain_validates_with_dxil.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 995 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main80f4819too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@raylitebull on GitHub · 2026-11-25 00:47 UTC · original
Overlap note: full credit to #1906 (@Decodere), which already covers the shared
simplify_opconstantBitCast, nested same-conditionSelect,zext(i1)compare, andselect(c, 1, 0)folding inmodule/opt.rs.Once #1906 lands (or in our next update), we will trim #1972 down to only the independent
propagate_select_guardspass andknown_lt_32bitmask rules, and address @WebIdentity1's loop-header phiDemand::Anylatch-propagation catch.@raylitebull on GitHub · 2026-11-25 00:48 UTC · original
Thanks for catching and proving the loop-header phi case, @WebIdentity1!
Updated
#1972cleanly on top of6567c5fin commit6e1b44f(crates/xcl/src/gpu/dxil/module/opt.rs):Op::Phiincoming operands asDemand::Anybefore the reverse-RPO walk inpropagate_select_guardsso back-edge phi consumers visited after the loop latch cannot leave aGuard(c)requirement on a latch value.select(g, ...)chasing whenrepl[idx]replaces an eligibleselect(g, t, _).loop_header_phi_preserves_latch_select_guard.Verified locally with
cargo check --workspace --tests,cargo test -p xcl --lib gpu::dxil::module::opt::tests(5 passed, 0 failed,dxil 1.8.2502.11validated), andloop_entered_in_the_middle_is_split(1 passed, 0 failed).@raylitebull on GitHub · 2026-11-25 01:12 UTC · original
Trimmed and rebased
#1972cleanly ontoaa9ab8ain commit8d419c0:simplify_opconstantBitCast/Select/zext(i1)rules that overlap with#1906(thanks@Decodere!), keeping ONLYpropagate_select_guards(with loop-headerOp::PhioperandDemand::Anypre-seeding per@WebIdentity1's catch + transitiveselectchasing),known_lt_32+ full-EXEC lane-bit fold (and(lshr(-1, s), 1) -> 1),run_cse_simplify, andTRANSLATOR_VERSION8 -> 9.cargo check --workspace --testsandcargo test -p xcl --lib gpu::dxil::module::opt::tests(5 passed, 0 failed,dxil 1.8.2502.11validated).@Fran-co-F on GitHub · 2026-11-25 01:48 UTC · original
RADV numbers for the two
ScreenProbesgiants: the guard pass cutsActivateProbes' driver build from 281 s to 105 s, and does not helpActivateRays, which still runs out of memory.Setup: RX 9070 XT 16 GB (RDNA4), Mesa 26.3.1 RADV (ACO), Ryzen 7 9800X3D, 32 GB RAM, CachyOS. Wine 11.17, vkd3d-proton
ec20719(release, @0naku's two dxil-spirv patches). This PR's head8d419c0merged into my local tree (Wine fixes, local diagnostics, and the DXC optimizer patch from my comment on #1426, which runs after the translator in both arms), release, cross-built. Each program built alone:xcl shaders shaders.rpf --precompile --only cs --pipelines, with a local filter to one record hash. Settings:XCL_DIRECT_DXIL=all, the DXC optimizer pass list from #1426, cold (MESA_SHADER_CACHE_DISABLE=true,VKD3D_SHADER_CACHE_PATH=0, a new translation cache per arm), and a systemd scope withMemoryMax=26G, no swap. The control arm is the same binary withXCL_DXIL_NO_OPT=guard. One run per arm.XCL_DXIL_NO_OPT=guardCS_ScreenProbes_ActivateProbes(56c0cd3b82a00c6e)CS_ScreenProbes_ActivateRays(95cc13288a27a96e)ActivateProbes, the pass shrinks the translated DXIL by 4.4 % (3 457 829 → 3 307 013 bytes), and the build takes less than half the time.ActivateRays, the pass changes the translated DXIL by 0.13 % (1 456 029 → 1 454 157 bytes). RADV still grows past 26 GB, as in #2025's RADV numbers on the HLSL path.ActivateProbesholds the single huge-compile slot for minutes during world load. The 15xcl-psoworkers wait inbig_compile_turn, and the title's watchdog (+0x23cf683) ends the run.Not tested: more than one run per arm, other programs, Windows.
AI use: Claude Code (Claude Opus 5.5) ran the builds on my machine and wrote this.
@raylitebull on GitHub · 2026-11-25 02:08 UTC · original
Thanks for the RX 580 repro and clear root-cause diagnosis,
@philip-roy-jones!Fixed the cross-lane quad-derivative miscompilation in
e3dfb2e(rebased cleanly onto94193f0, also dropping the redundantkernel.rsTRANSLATOR_VERSIONbump after#1947):opt.rs::guard_eligible):guard_eligiblepreviously allowed anyFnAttrs::ReadNonecall (not ending in.f64) to propagate per-laneselectguards to its operands, which swept quad derivatives (dx.op.unary.*opcodes83..=86,DerivCoarseX/YandDerivFineX/Y) into guarded simplification because they share theReadNonedeclaration with lane-local math.ReadNonecatch-all inguard_eligiblewith an explicit allowlist of strictly lane-local, non-trappingdx.op.*intrinsics (op_code in 6..=42 | 44..=56 | 124..=132— pure math/bit/conversion ops only). All cross-lane ops (83..=86derivatives,87..=89Eval*,Wave*/Quad*, implicit-LOD texture ops, handle constructors216..=218) returnfalseand keepDemand::Any.opt::tests::guarded_derivatives_and_cross_lane_ops_preserve_select_operandsandgraphics_tests::guarded_derivatives_read_neighbor_values(DXIL validation/disasm + 8x8 fullscreen draw test).Pushed
e3dfb2efor GitHub ActionsBuild and testand fresh RX 580 / NVIDIA re-testing!@philip-roy-jones on GitHub · 2026-11-25 02:08 UTC · original
@raylitebull, here is the patch for the quad-derivative readback on
8d419c0. The guard pass treatsdx.op.unaryas lane-local because it is markedreadnone. Its four derivative opcodes read neighboring lanes. If an even pixel reads a derivative, the odd pixel’s selected input still matters.The patch keeps those four calls out of guard propagation. The added 8×8 draw checks coarse and fine differences in both directions. On the RX 580, the first pixel went from four zeroes to four sevens, and the repaired shader matched all 256 expected output components. GPU test report
Patch against 8d419c0 (apply with git apply)
AI use
OpenAI Codex, GPT-6.2 Astra at maximum reasoning effort, wrote the change and regression test and ran the comparisons. I checked the optimizer change and the test before sharing them.
@WebIdentity1 on GitHub · 2026-11-25 00:38 UTC · original · edited 2026-11-25 02:16 UTC
e3dfb2e: derivative repair verified on RTX 3090; small unit-test correctionResponding to the NVIDIA retest request: the runtime repair on exact
e3dfb2e02ce639f3ca84ce130bbaef1dcc6a9493produces all 256 correct derivative output components. Our earlier loop regression also remains correct for all 128 words. Credit to @philip-roy-jones for the derivative diagnosis/fixture and @raylitebull for the runtime repair.One remaining failure is in the new unit test, not the GPU output.
guarded_derivatives_and_cross_lane_ops_preserve_select_operandscreates four identical selects, then asserts each derivative retains its original instruction ID. CSE legitimately shares the first select: opcode84 getsInst(2)rather than its originalInst(6). The small test-only patch below checksOp::Select(c, two, nine)instead, retaining the exact predicate and both alternatives. The existing lane-local FAbs-fold check remains intact.Tested — native Windows10 Home19045, Ryzen7800X3D, RTX3090 driver591.74 (32.0.15.9174), Rust/Cargo1.98.1MSVC, DXC/DXIL1.8.2502.11, debug.
XCL_ADAPTER=3090,XCL_SPLIT_WAVE64=1; runner printed the actual adapter.ReadNone && !f64catch-allThe negative control is a single-rule overlay on this head, not a parent checkout. It keeps the author's earlier loop repair, which passes in all snapshots. The pre-correction negative control also gave 6/2/0/0 and the same 128 wrong components. The first pixel is
[0,0,0,0]with the old call rule and[7,7,7,7]with the repair.Test-only diagnostics count the complete 8×8×4 readback and print the adapter; the draw's disassembly assertion was moved after readback so the negative control actually executes the shader. No assertion was removed. All four 319-file manifests match before/after and local snapshots; XCL rebuilt each time.
Not tested — full workspace, retail smoke, new AMD/Intel runs, compilation time or memory improvement. The six optimizer units include the existing chain-reduction check, but that is not a timing measurement. No runtime patch, commit/push or competing PR from this follow-up; required merge checks remain separate.
AI use — Codex (GPT-6) reviewed the new head, ran the comparison, diagnosed/corrected the unit-test identity assertion and prepared this report.
Test-only correction against e3dfb2e
Update: the author's repair at
6e1b44f2736825759c78194096f8afe64725c75cresolves this GPU reproducer. Tested that head with only the same 55-line GPU regression appended; none of my proposed optimizer changes were applied. The narrower phi-operand seeding passes, including the author's new loop test and the original guard-chain simplification test: 6 passed / 0 failed / 0 ignored, zero skips. All 128 GPU output words match; inactive/active carried values are[43, 8].Same native Windows 10 19045 / Ryzen 7800X3D / RTX 3090 driver 591.74 / Rust 1.98.1 MSVC / DXC 1.8.2502.11, debug;
XCL_ADAPTER=3090,XCL_REQUIRE_GPU=wave64,mesh,XCL_SPLIT_WAVE64=1,XCL_DIRECT_DXILunset. All 311 source hashes matched before and after, and the build recompiled XCL. This closes the specific wrong-output finding below. No new full-suite, retail, AMD or performance result is claimed. AI use for this follow-up: Codex (GPT-6), source review, running the existing regression and report preparation.Original reproducer, proposed patch and earlier results
Confirmed a wrong-output regression in
propagate_select_guardsatc04f6c6f81280a63389d01b101500448212694c9. A phi is initialized asDemand::Any, but its operands receive that demand only when the reverse walk reaches the loop header. By then the latch definition has already been visited, so the demand does not reach its inputs. A value shared with a guarded consumer can therefore lose its select even though the next iteration needs its inactive value.The public synthetic loop forms
v = select(active, 7, 42), usesv + 1unconditionally through the header phi, and separately observesv * 3only underactive. After two iterations, inactive lanes must carry43, not8.Tested — native Windows 10 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug:
80f4819+ regression: 2 passed / 0 failed / 0 ignored, all 128 GPU output words correct.8rather than43.The fix seeds every non-eligible instruction's operands as unconditionally demanded before the reverse walk, including phi back-edge operands. It keeps the traversal linear and does not disable guarded-value optimization.
Full comparison:
cargo build --locked --workspacepassed on head+test and candidate.cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-outputreturned 995 passed / 2 failed / 45 ignored on each, across 20 targets, with identical 26 SKIPPED messages (19 wave64 subcases, three refused per-lane subcases, two debug-layer checks, driver-cache-disable and heap-window checks).The failure sets differ: head fails the new loop test plus the known
gpu_clamp_and_omod_per_instruction; candidate fixes the loop but additionally hitsd32s8_targets_take_their_own_size_of_video_memoryatCommandList::Close(0x80004005). The unchanged candidate passes that depth test in isolation 1/0/0, no skip. That test is byte-identical across the pair and has previously failed on a separate main baseline in our #1834 comparison; its intermittent failure is not diagnosed here. The full suite is not green. All source snapshots matched 311-file SHA256 manifests before/after; source switches forced recompilation.Candidate fix and GPU regression (62 added lines)
Not tested: retail shaders/gameplay/smoke, AMD/native wave64, or measured compile-time/memory benefit. This is a synthetic DXIL-loop correctness finding; no merge-readiness claim. No competing PR or source push.
AI use: Codex with GPT-6 Astra inspected the pass, wrote the candidate and synthetic GPU regression, ran the Windows comparisons, and drafted this report.
@philip-roy-jones on GitHub · 2026-11-25 01:57 UTC · original · edited 2026-11-25 02:28 UTC
RX 580 retest of the author’s fix at
e3dfb2e02ce639f3ca84ce130bbaef1dcc6a9493The 8×8 draw on the updated PR returned all 256 expected output components. At the author’s requested reference
94193f0c8a4a01bf6d3ca3cd2e3a608f0444eb84, copying only the new draw test gave the same result. The PR commit’s immediate Git parent isa1a2978. Author’s updateXCL_DIRECT_DXIL=1,xcl-gpu run cargo test --locked -p xcl --lib guarded_derivatives -- --test-threads=1 --nocapturegave 1 passed, 1 failed, 0 ignored, 0 skipped on the PR. The GPU draw passed. The optimizer unit test failed for derivative opcode 84, comparingInst(2)withInst(6)after common subexpression elimination. On the reference with the draw fixture added, the same command filtered toguarded_derivatives_read_neighbor_valuesgave 1 passed, 0 failed, 0 ignored, 0 skipped. Windows CI failuree3dfb2e, the fixture constructed its identical input select once before the four derivative calls. With all original assertions in place,cargo test --locked -p xcl --lib guarded_derivatives_and_cross_lane_ops_preserve_select_operands -- --test-threads=1 --nocapturegave 1 passed, 0 failed, 0 ignored, 0 skipped.cargo build --locked --workspace -j 4andxcl-gpu run cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output. The full suites used default backend selection. The failing optimizer unit test was the sole additional failure on the PR. Both suites had the same 65 explicit skips, included in their pass counts.94193f0e3dfb2eBoth release builds exited early with
0xc0000409during the 60-second retail smoke. Neither produced a final frame count. I usedcargo build --release --locked -p xcl -j 4andxcl-gpu run powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\smoke.ps1 -Game <folder> -Title Retail -Seconds 60 -Xcl <release-xcl.exe>withXCL_DIRECT_DXIL=1and separate, initially empty data and DXIL-cache directories.Generated smoke blocks for the reference and updated PR
Radeon RX 580 (31.0.21925.1001), Ryzen 7 7700X, Windows 11 Pro 26200.9974, Rust 1.100.0 MSVC, DXC and validator 1.9.2609.5. OpenAI Codex, GPT-6.2 Astra at maximum reasoning effort, ran the retest and prepared these results.
RX 580 GPU readback at
8d419c0— a pixel shader with alternating lane predicates returned[0, 0, 0, 0]at pixel (0, 0). The expected result is[7, 7, 7, 7]. The same draw matched the CPU expectation at all 64 pixels on the PR’s parent, on the PR withXCL_DXIL_NO_OPT=guard, and with a local change that preserves derivative inputs. Reviewed patch and regression test · Original measurement claimThe 8×8 draw uses XCL’s direct DXIL builder. On this head, a source search found explicit calls to
Shader::derivin builder tests only. For each axis, even pixels supply 2 and odd pixels supply 9. The shader evaluates the coarse and fine derivatives across the quad, then selects the derivative for even pixels and −1 for odd pixels. DXC’s validator accepted the shader in every run.Tested
guarded_derivatives_read_neighbor_valuesto the graphics tests.xcl-gpu run cargo test --locked -p xcl --lib guarded_derivatives_read_neighbor_values -- --test-threads=1 --nocapturegave 1 passed on parentaa9ab8a3e7b738ec48899e37805f6a7d2d22da53, 1 failed on head8d419c01b1a0aba6e04c9dea8b9e7b795816e65e, 1 passed with the guard pass disabled on that head, and 1 passed with the local repair and the pass enabled. All four runs had 0 ignored and 0 skipped.xcl-gpu run cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output(debug, default backend selection, sample variables unset) produced the counts below. The 97 failing test names and the 61 explicit skips matched across all three trees. Libtest includes those skips in its pass count.With the repair, the existing five optimizer tests passed. The separate native-wave64 compute test
gpu_divergence_through_execalso passed withXCL_DIRECT_DXIL=1. Both filtered runs had 0 failures, 0 ignored and 0 explicit skips.Retail shader compilation
I translated five compute records in release with four memory windows and
--split 0. On all five, the PR and local repair produced byte-identical validated DXIL and static samplers. CPU times are medians fortranslate_computeafter one warm-up per process, with six measurements per revision and the order rotated across parent, PR and repair. PSO times are medians for the firstCreateComputePipelineStateon the RX 580, with three interleaved trials per revision. Parentheses give the range.select i1, parent → PR06ac9019d1c01f0e2e0055c25f49848a6e148dbd563de20595cc13288a27a96ec5696074df0b1cbcTo reproduce a row’s shader output, run
xcl shaders <pack> --direct --hash <record-hash> --validate --split 0 --windows 4 --threads 1 --timeout 90 --dump <dir>. The driver builds used each record’s static samplers, the XCL ABI root signature, an empty cached-PSO field and a fresh executable name per first-use trial. Windows returned0x887a002dfromShaderCacheControl. Repeating the same executable for06ac9019d1c01f0etook 1.3 ms on the parent and 6.1 ms on the PR. These are first-call timings with the driver’s implicit cache available. The largest record,95cc13288a27a96e, requests wave32 and was checked through DXIL validation only.A separate seeded retail sample (
xcl shaders <pack> --direct --validate --seed 1972 --sample 96 --split 0 --windows 4 --threads 1 --max-bytes 0 --timeout 90) validated 96 programs per revision, including 51 pixel shaders, 29 mesh, 10 compute, 4 vertex and 2 geometry. The parent and PR differed on 95 programs, reducing total DXIL from 10,932,744 to 10,438,868 bytes (4.52%). All 96 PR outputs matched the repair byte for byte.On the largest record, disabling guard propagation on the PR head left 68,620 scalar selects and 3,616,632 DXIL bytes. Turning it back on removed another 44 selects and 1,200 bytes. Most of the 11,240-select reduction from the parent was already present with that pass disabled. Each shader timed on the driver had both faster and slower PR trials. All driver trials and 78 of the 90 CPU observations finished before an Orca restart. The remaining 12 CPU observations used the same binaries and settings afterward.
Regression run
Both release builds ran
xcl-gpu run powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\smoke.ps1 -Game <folder> -Title Retail -Seconds 60 -Xcl .\target\release\xcl.exeon the RX 580 withXCL_DIRECT_DXIL=1and separate, initially empty XCL data and DXIL-cache directories.Generated smoke blocks, parent and PR head
Not tested
Execution of the retail shader records with game inputs, other adapters, and world-load completion. The clean parent and PR head both terminated early with
0xc0000409in their 60-second RX 580 title smokes withXCL_DIRECT_DXIL=1. Neither produced a final frame count.AI use
OpenAI Codex, GPT-6.2 Astra at maximum reasoning effort, wrote the synthetic shader and local repair, ran the checks and prepared the report.
@JJAutoCompare on GitHub · 2026-11-25 03:16 UTC · original
PR #1972 — Intel Arc A770 guarded derivative verification
Tested
e3dfb2e02ce639f3ca84ce130bbaef1dcc6a9493. GitHub showed PR #1972 open at this head before and after the run.32.0.101.9175, and Rust1.100.0 (0ef1bc386 2026-11-09),x86_64-pc-windows-msvc. The fixture loadeddxcompileranddxil1.9.2609.5from the configured DXC directory.SKIPPEDlines, so both DXC validation and GPU readback ran.2.0. The fullscreen 8×8 draw matched all 64 RGBA pixels (256 components) on readback. Each pixel matched[ex, ex, ey, ey], whereexwas7.0on even columns and-1.0on odd columns, andeyfollowed the same rule for rows.XCL_DXIL_NO_OPTwas unset.build.logandarc-test.logare alongside this report.Not tested
AI use
gpt-6.2-sol) ran the checked-in fixture and wrote this report.@DavidM1911 on GitHub · 2026-11-25 03:19 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 10:38 UTC · original
Fixed the CI assertion in
opt::tests::guarded_derivatives_and_cross_lane_ops_preserve_select_operandsin commit7e36ea5(rebased onto56ec08d, keeping the strict lane-localdx.opallowlist6..=42 | 44..=56 | 124..=132frome3dfb2e):select(c, 2.0, 9.0)instructions intoInst(2)(none of quad-derivative opcodes83..=86were folded to2.0, andgraphics_tests::guarded_derivatives_read_neighbor_valuesalready compiled cleanly).guarded_derivatives_and_cross_lane_ops_preserve_select_operandsto share ones = select(c, 2.0, 9.0)across all 4 quad derivatives (83..=86, assertingargs[1] == s) and the contrast lane-localFAbs(6, assertingargs[1] == 2.0).Thanks again
@philip-roy-jones— pushed7e36ea5for GitHub ActionsBuild and testand re-testing!@raylitebull on GitHub · 2026-11-25 10:52 UTC · original
Rebased
#1972cleanly onto13c2a405in commit528ca109, resolvingcrates/xcl/src/gpu/dxil/module/opt.rsdoc-comment and EOF test conflicts alongside#2194(e64bd17bsimplify_cfg).Verified locally (
cargo check --workspace --tests+cargo test -p xcl --lib gpu::dxil::module::opt::tests:11 passed, 0 failed,dxil 1.8.2502.11validated) and pushed528ca109.@Toons29 on GitHub · 2026-11-25 13:02 UTC · original
Regression run of
528ca109on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % 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; a script posted this right after the run, with both blocks exactly as printed.@thehollowedone on GitHub · 2026-11-25 14:55 UTC · original
Independent Windows check of 528ca109 and its clean local integration onto main 06c9f55. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC and DXC 1.8.2502.11.
XCL_DXIL_NO_OPT=guard. All four fresh runs validated the DXIL and matched the expected coarse and fine X/Y derivatives at all 64 pixels. Zero skips. Command:cargo test --offline --locked -p xcl --lib -j 4 guarded_derivatives_read_neighbor_values -- --test-threads=1 --nocapture.cargo build --offline --locked --workspace -j 6and finished the workspace suite with 1,271 passed, 0 failed, 46 ignored, including 26 runtime skips in the pass count. Both assertions that failed in Windows CI passed on the integration. The test expectation fixes are already on main. Suite command:cargo test --offline --locked --workspace --no-fail-fast -j 6 -- --test-threads=4 --nocapture.Synthetic rendering verification. No new retail smoke or compile-time measurement. The existing exact-head smoke pair is in the discussion.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.
@anes66 on GitHub · 2026-11-25 14:49 UTC · original · edited 2026-11-25 15:21 UTC
CPU output-model check on exact head
528ca1096fa9faca8d1b04dd7c65d623bdb5e486: guarded quad derivatives keep the neighbor values selected in lanes where the output guard is false. Optional companion 6e84f93 adds one test only, directly on that head.Tested
selectinputs to all four quad derivatives (83–86), and guarded outputs. Lane-local FAbs (6) is the contrast. A small test-only interpreter evaluates the actual live IR, before and after optimization, against an independent explicit four-lane reference.cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -j 2 -- --nocapture --test-threads=1: 12 passed / 0 failed / 0 ignored / 0 skips. This includes the existing VALU-chain DXIL validator check using SDK DXC/DXIL 1.9.2602.17; the new quad fixture itself is an IR/model check.0001, with incorrect observed derivative outputs. Restored before the final passing run and commit.Not tested
GPU execution, AMD/NVIDIA/Intel driver behavior, pixel-shader validation of the new fixture, helper-lane/discard behavior, NaNs/denormals, full workspace, release or a title. This supplements the PR's structural and GPU fixtures; it does not replace the outstanding GPU check.
Integration follow-up
Combining this with #1906 exposes an operand-order assumption in
loop_header_phi_preserves_latch_select_guard: commutative CSE legitimately writesadd(1, s), while the test requiressin operand zero. Optional 84a8c7d, directly on528ca109, checks the exact{s, one}pair in either order. It still rejects replacingswitha, and now checks the increment too. The exact test passes 1/0/0/0 on the standalone head with this test-only adjustment.A local integration snapshot of #1906, #1860, the proposed #2076 rebase, #1972 and #2322 on main
06c9f55is cf25b62. Manual optimizer resolution preserves separate fold/CSE switches, bitcast/select aliases, conservative guard eligibility and f64-only DCE exclusions. 29 targeted CPU/validator checks passed, plus 3 compact-policy checks; the CPU quad model also passed separately withguard,fold,cseandfold,csedisabled.cargo build --locked --workspace -j 2passed. No GPU execution, title run, full test suite or merge-readiness claim for this combined snapshot.@raylitebull on GitHub · 2026-11-25 18:13 UTC · original
Thanks @Toons29 for the exact-head RX 9070 60 s
scripts/smoke.ps1pair on528ca109(1630vs1628frames,0device removals,0crashes) — added to the PR description! Thanks also to @thehollowedone (RTX 3080 Ti) and @anes66 for verifying528ca109.@Kalmarv on GitHub · 2026-11-25 23:30 UTC · original
@raylitebull, a measurement next to this PR, from work on the size of the DXIL we hand the NVIDIA driver (#1096).
Bound DXIL over 802 compute programs a retail title (title: ea3b5e4d) has in use at its device-memory crash, translated offline with a release
xcl.exe(no GPU). For this I rebased this PR onto main; the only conflict was in the tests module ofopt.rs, and I kept both sides:e1d84b7d(same code as6d12f58a)The fold has the same goal as
propagate_select_guards: read throughselect(exec, new, old)when no lane observesold. It tracks, per value, where that value is observed (unused, only where one condition holds, all lanes), and that reaches more selects. On its own it saves 8.1 % of the bytes, against 4.1 % for this PR. With it in place, this PR saves another 1.0 MiB (0.5 %). On the NVIDIA driver (RTX 5070 Ti, driver blob bytes), the fold on main cuts the native code of 4 of the largest of these programs by 5.4 % (3.60 → 3.40 MB).Branch, this PR rebased onto main plus the two passes: https://github.com/Kalmarv/xcl/commits/op-diet/on-1972. Each pass has a GPU test that translates the same program with and without it and compares every VGPR of every lane and the SGPRs. If you want it, I can offer it as a PR into your branch, building on your allowlist and tests, or we can combine the two another way. Your call.
Tested: on an RTX 2060 (NVIDIA 595.91) under Wine 11.21 + vkd3d-proton, at
dffad791, both new GPU tests pass, andgpu::dxilgives 186 passed / 2 failed / 3 ignored against 181 / 2 / 3 on maine1d84b7d. The same two tests fail on both (known gaps of that Wine stack: a memory-window test and an fma-precision test); themodule::optandselect_testsunit tests pass on Windows without a GPU.Not tested yet: the GPU tests on Windows / NVIDIA for this combination, native size of this combination, a title run.
AI use: Claude Code, Claude Opus 5.5 (code, tests, measurements, this comment).
@DavidM1911 on GitHub · 2026-11-26 06:51 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.