shader: pixel_aot forward branches on a scalar compare (s_cbranch_scc0/scc1) — scope question #1406
Open
opened 2026-11-24 10:59:16 +00:00 by MasterDomino
·
10 comments
No Branch/Tag specified
main
codex/indirect-large-backed-views
codex/word3-preflight-check
codex/vertex-table-two-records
codex/live-index-alias
codex/copied-vertex-buffer-srv
codex/windows-stage-test-output
codex/preserve-live-srv-retirement
codex/share-render-target-tracking
codex/sgd5-negative-offset-fixture
coverage-dashboard
codex/mesh-loose-root
codex/mesh86-cache-padding
codex/xmem-scatter-preflight
codex/mesh-depth-ps
codex/indirect-dispatch-refresh
codex/compute-container-index
codex/startup-compute-formatted-load
codex/compute-indirect-producer
codex/compute-atomic-soffset
codex/mesh-dual-handoff
codex/startup-run-sh-watcher-control
codex/queue31-page-alias
codex/indexed-indirect-compute-root
codex/typed-buffer-view-metadata
codex/translated-indexed-address-alias
codex/fixed-mesh-create-result
codex/xmem-section-lease
codex/startup-slot86-mesh-cache
codex/restore-mesh-barrier-iteration
codex/translated-indirect-upload-index
codex/xapu-completion-opt-in
codex/translated-indexed-rect
codex/translated-indexed-indirect
codex/startup-mesh-lds-integration
codex/startup-console-ms24
codex/startup-slot57-mesh-request
codex/indirect-copy-provenance
codex/present-color-producer-trace
codex/compute-dispatch-binding-trace
codex/translated-indirect-table-buffers
codex/indirect-copy-provenance-base
codex/mix-half-literal-source
codex/translated-indirect-draw
codex/xmem-scatter-diagnostics
codex/slot148-recording-upload
codex/slot70-loading-art-verified
codex/command-list-upload-arena
codex/recover-failed-command-list
codex/startup-heap-timing-notes
codex/align-audio-input-timeline
codex/synthetic-depth-export-control
codex/startup-texture1d-on-windows
codex/1629-packed-position-fixture
codex/cpu-srv-refresh
codex/stream-root-srv-draw
codex/audio-mixer-timer
codex/startup-reload-published-shader
codex/priority-integrate-1284
codex/guest-sixteen-page-record
codex/aot-placed-dxr-batch
codex/guest-directory-selection
codex/gamesave-enumerate-read
codex/readme-archive-to-pixels
codex/pe-placed-view-draw
codex/archive-directory-gpu
codex/slot133-dxr-build
codex/materialize-placed-vertex-view
codex/dstorage-directory-offsets
codex/xg-nine-bc-copy
codex/xg-slot10-bc64-arrays
codex/dxr-guest-address-readback
codex/gpu-va-high-bits
codex/clarify-diagnostic-startup-scope
codex/xg-six-levels
codex/typed-derived-blend
codex/english-legal-text-progress
codex/address-bc-4ks
codex/dstorage-bounded-file-read
codex/wide-srv-offsets-menu
codex/startup-memory-srv
codex/bound-view-tail
codex/language-selector-readback
codex/setup-menu-progress
codex/cpu-plane-refresh
codex/startup-ubyte-vertex
codex/presenter-window-selection
codex/startup-uniform-buffer-lane
codex/intro-loop-timing
codex/static-clzero-loops
codex/document-rtx-intro
codex/startup-insertq
codex/nv12-startup-texture
codex/stream-stage-draw
codex/startup-null-uav-format
codex/startup-draw-capture
codex/shorten-windows-checks
codex/dstorage-rfc1950
codex/startup-dump-fence
codex/pr1135-review-base
codex/startup-stream-requests
codex/startup-chroma-view
codex/readme-graphics-pipeline-streams
codex/static-crt-free-tls
codex/arc-140t-rtx-5080-laptop-gpu-reports
codex/main-startup-progress-entry
codex/signed-dxil-catalogue
codex/reloc-free-preferred-base
codex/quad-dpp-bit-mask
codex/raw-srv-bounds
codex/rx9070-31044-hardware-report
codex/gpu-page-source-provenance
codex/runtime-placeholder-interior
codex/gpu-copy-queue-tile-order
codex/pe-pin-external-providers
codex/xmem-placeholder-reservations
codex/xmem-shared-physical-pages
codex/pe-package-startup
codex/xmem-tools-memory-query
codex/cpu-stack-output-import
codex/pe-load-security-cookie
codex/record-three-bvh-retests
codex/cpu-rbp-frame-anchor
codex/xmem-default-startup
codex/record-rtx-3050-ti-9597
codex/docs-readme-start-here
codex/check-compute-mad24-truncation
codex/docs-discord-community
codex/bound-rcx-branch-mutants
codex/rtx5060ti-bvh-62114
codex/837-neutral-readme-disclaimer
codex/record-rtx-3070-ti
codex/title-neutral-public-wording
codex/exe-shadow-frame-submissions
codex/exe-shadow-runtime-chain
codex/readme-polish
codex/gpu-coverage-nov23
codex/spirv-minlod
codex/shadow-shim-device
codex/exe-two-shadow-frames
codex/shim-dispatch-cleanup
codex/fix-spirv-cache-probe
codex/sampler-use
codex/ballot-bit-extract
codex/packed-fma-release
codex/cpu-packed-fma-o2
codex/publish-coverage-dashboard
codex/mesh-cbv-binding-order
codex/spirv-window-fixture
codex/ps-e32-float-uint
codex/ps-cbuffer-reads
codex/fixed-profile-rescan
codex/shim-compute-integration
codex/readme-visible-coverage
codex/readme-research-navigation
codex/integrate-pr-256
codex/indexed-mesh
codex/sampled-coverage
codex/first-ms
codex/dual-ps
codex/ps-attribute
codex/compute-first
codex/ps-export
codex/readme-research-status
codex/ps-layout
codex/blast-window
codex/chart-caption
codex/reviewer-roles
codex/blast-aot
codex/archive-program
codex/crc-stream-program
codex/exe-image-data-chain
codex/local-cpu-fixture-coverage
codex/exe-bound-frame-chain
codex/exe-mapped-comparison
codex/contribution-dependencies
codex/exe-entry-aot
codex/bink-frame-heap-integration
docs/hardware-seven-reports
codex/bink-custom-heap
codex/bink-heap-callers
codex/discussions-entry-points
codex/gpu-community-batch-64
codex/ffx-scratch-writers
codex/generic-project-documentation
codex/ffx-dispatch-rcas
codex/four-windows-gpu-reports
codex/title-neutral-project-wording
codex/community-coverage-provenance
codex/rcas-packed-texels
codex/community-gpu-retests
codex/community-build-and-gpu-reports
codex/ffx-provider-loop
codex/ffx-recurrent-views
codex/ffx-recurrent-resource
codex/amd-wave64-reports
codex/ffx-backend-slots
codex/upscaler-device-init
codex/ffx-context-lifecycle
codex/ffx-version-query
codex/ffx-provider-contract
codex/typed-object-callback
codex/cpu-ordinal-import
codex/chained-cpu-ranges
codex/cpu-import-call
codex/cpu-direct-call
codex/cpu-leaf-aot
codex/community-project-status
codex/script-state-path-replay
codex/script-state-evidence
codex/bc7-resident-tail
codex/bcpack-mip-tail
codex/bc7-texture-draw
codex/asset-ranges
codex/pixel-constants
codex/pixel-aot
codex/pre-exe-workloads
codex/root-signature-device-coverage
engineering/packed-bvh-leaves
engineering/bvh-build-and-update
engineering/intake-root-roundtrip
community/gpu-check-release
community/english-contributor-entry
gpu-check-v0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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
R0Y00/Xbox2Windows#1406
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:59:16Z.
With masked regions now accepting the s_mov close and one else arm (#1328, #1371), I measured which control flow still separates the local pixel programs from
pixel_aot. Scalar-condition branches turn out to be much more common than deeper region nesting. This is a proposal and a scope question only; no code yet.Setup
upstream/mainat04e307cf, LLVM 15.0.7LLVM-C.dll(pixel_aot.disassemblewith offsets).What remains after #1371
s_cbranch_execzs_cbranch_vccnzs_cbranch_scc0s_cbranch_scc1s_branchs_cbranch_vcczForward SCC branches
SCC is written by scalar instructions, so a branch on it is taken or not taken by the whole wave. In this input it is almost always a scalar compare. Last SCC writer before the branch:
s_cmp_eq_*s_cmp_lg_*s_andn2_*s_cmp_lt_*s_cmp_gt_*s_cmp_eq_u64s_cmpk_eq_*s_cmp_ge_*pixel_aotalready tracks a compare's SCC as an HLSL bool (scc{i}, read bys_cselect/s_cmov).Shapes of the forward
s_cbranch_scc0/s_cbranch_scc1branches:s_branchover a branch-free second blockOf the 36,365 skip and diamond blocks, 11,348 contain only ALU and scalar work. 25,017 contain an image, buffer, scalar load or export, and 3,159 write EXEC.
Proposal
Stage 1: one forward
s_cbranch_scc0/s_cbranch_scc1over a branch-free block.s_cmp_*/s_cmpk_*result on tracked scalar operands. Any other or untracked SCC is refused.scc0/scc1, and the branch dropped.Later stages, each a separate review:
s_branch;ifinstead of selects;s_cbranch_vccz/vccnz, whose "any lane" meaning needs a uniformity argument first.Questions
ifblocks, so that later stages with samples share one lowering?If this direction works, I'd take stage 1.
Limits
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:22:58Z.
A single forward SCC-led skip is a good first PR. A select merge is fine for side-effect-free ALU that is safe to evaluate on either path. Start with vector writes so the first change can reuse the existing masked-region definedness checks. Require a tracked uniform scalar compare, the real forward target boundary, and an incoming definition for any VGPR later read after a conditional write. Keep memory, EXEC writes, observable scalar/wave updates and nesting out of this slice. The proposed polarity and dropped-branch controls, both directions with a runtime constant, and LLVM 15 round trip cover the key cases.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:23:52Z.
Claiming stage 1 as scoped: one forward
s_cbranch_scc0/scc1skip over a vector-only block, a tracked uniforms_cmpSCC, the real forward target boundary, select merges with the existing masked-region definedness (an incoming definition required for any VGPR read after a conditional write), and memory, EXEC writes, scalar/wave updates and nesting kept out. Tests: both polarities and the dropped branch as mismatching controls, taken/not-taken through a runtime constant, LLVM 15 round trip. I'll link the PR here.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:33:26Z.
Stage 1 PR: https://github.com/R0Y00/Xbox2Windows/pull/1440. Tracked
s_cmp/s_bitcmpSCC only, real forward target, vector-only block merged with selects on SCC/!SCC using the masked-region definedness (also checked at the target), SCC/VCC preserved. WARP and RX 9070 XT: 6/6 cases (flag 0/1/7 for both forms) match, 6/6 polarity and dropped-branch mutant cases mismatch; 14/14 region and skip CTests pass.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:42:56Z.
The single forward SCC skip landed in #1440 at
ea475f35. The Windows Release SCC-skip and existing EXEC-region fixtures passed on RTX 4060 Laptop and WARP (4/4, no skips). This covers one forward skip over vector ALU using a tracked uniform comparison, including the polarity and dropped-branch controls. The diamond and blocks with observable side effects remain outside this implementation.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:44:41Z.
With stage 1 on main (#1440), here is a plan for stage 2, the diamond. On the local input that shape is 9,004 branches in 3,201 records. I'd like your go-ahead before coding.
Shape
Scope
s_cmp/s_bitcmpSCC.s_branch. Thes_branchmust be the last instruction of block A and land after block B. A diamond whose conditional branch lands anywhere else stays a stage-1 skip or is refused.cond_A ? A : B, with the pre-branch value standing in for a block that did not write it. A register undefined before the branch and not written in both blocks stays undefined after JOIN.s_branchstay out.Tests
s_branchdropped (A falls through into B);s_branchor on JOIN;s_branchnot last in block A, landing inside block B, or going backward;Does this match what you want for stage 2? If so I'll take it.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:04:27Z.
Go ahead with stage 2 as a single structured forward SCC if/else diamond on top of #1440. Reuse the tracked uniform
s_cmp/s_bitcmpcondition and the existing branch-target decoding. Both targets must be real instruction boundaries. The conditional edge must enter B immediately after A’s terminals_branch, and thats_branchmust land exactly at JOIN, after B. Keep both arms within the existing vector-only gate and preserve SCC, VCC, and EXEC. Leave nesting, backward branches, memory, waits, and other observable side effects out of this slice.Start both arms from the incoming VGPR state. Preserve an incoming value on any arm that leaves it alone. A value that was undefined on entry must be defined by both arms before a post-join read. Please keep both SCC polarities and runtime flags 0/1/7, the B-read-of-an-A-written register, the dropped-branch and flipped-polarity mutants, and the malformed-target rejection cases. Run the LLVM 15 round trip with both labels and report WARP and RX 9070 XT results separately.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T14:59:35Z.
Claiming stage 2 as scoped (single forward SCC if/else diamond on top of #1440). PR link to follow.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T15:14:43Z.
Stage 2 PR: https://github.com/R0Y00/Xbox2Windows/pull/1625. WARP: 6/6 diamond cases match, 8/8 mutant cases (stale-A, flipped polarity, dropped s_branch) mismatch. RX 9070 XT (
32.0.31044.16): same, 6/6 and 8/8. LLVM 15 round trip with both labels passes; malformed targets, nesting and definedness controls incheck_scc_diamond_controls.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T16:03:21Z.
Stage 2 is on main (#1625). Before coding anything further, here are the measurements for the next step, and a question about order.
Source: one local input (12,101 PS records, the same population as #711; 12,000 disassemble), on stages 1+2 (
117ebb8b), LLVM 15.0.7. Aggregates only.What the remaining uniform SCC blocks contain
34,180 forward SCC blocks in 6,877 records: 25,176 skips (6,682 records) and 9,004 diamonds (3,201 records). Blocks that contain
s_endpgmare not counted.s_waitcnts_load_*s_buffer_load_*image_sample*buffer_load_*image_storeexp,buffer_stores_cmp/s_cmpk, except 12 blocks (6 records) ons_bcnt1_i32_b64.EXEC at the branch (linear estimate)
Two possible next slices
A. Scalar state inside a uniform skip or diamond, at entry mask.
REGION_SALUsubset._lz. 125 of them also needv_madak_f32, which the translator lowers butREGION_ALUdoes not admit.B. Uniform branches inside a WQM span or under partial EXEC.
Sampling inside an arm would be a later stage. It would be either a select over a speculative sample (static binding, defined derivatives) or an HLSL
ifwith the merged values declared before it.Would you prefer A first as the small, low-risk slice, or B directly? I'll wait for your answer before claiming.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:05:51Z.
Stage 2 landed in #1625 at
874cc3fa. The SCC diamond controls are included in both serial and parallel form coverage, and the final head passed both Linux jobs and Windows. Independent RTX and WARP Release draws passed after resolving the test registration conflict. This covers the approved forward diamond. Further branch shapes still need separate evidence.