gfx2hlsl: lower the carry of adjacent compute address adds #2650
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2658"
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 RavenCurseBurg on 2026-11-26T00:55:55Z.
Change
For T2 of #2644, the startup compute translator now handles a numeric low-word add immediately followed by
s_add_u32 sN+1, 0, src_scc. On main and on both #1821 and #2577, the high add of this pair was refused. Three-revision reproductionThe low add emits its unsigned carry before writing the destination, which can also be an addend. The high add reads that bit and clears SCC, as adding 0 to a single bit always fits. A branch entering the high instruction skips the proof. The reader is enabled only when the low instruction actually emits numeric arithmetic. Symbolic descriptor adds, lane-mask inputs, an intervening writer, or a different high-word form retain their refusals.
Verification
At
ef563d82on Windows 11, the public compute fixture exercised the new path on WARP, GeForce RTX 4060 (32.0.15.9579) and Intel UHD Graphics 770 (32.0.101.5973). The synthetic gfx1013 program adds group IDs 0, 1, 2 and 3 to0xfffffffe, overwrites its input SGPR and stores the low word, high word and final SCC. The first two groups produce high 0, the next two high 1, and all four leave SCC clear. Each backend matched all 320 words, including the guard after each group. The entire dispatch fixture passed on each backend, with 22 matching programs and three expected failures.For binary verification I used LLVM 15.0.7's AMDGPU assembler in show-encoding mode. The fixture bytes matched. I ran the hardware command separately with
XBOX2WINDOWS_ADAPTER=NVIDIAandIntel. The local set of 93 host checks passed, including the gfx2hlsl checks and documentation links.Two extra compiled variants consumed 32 pairs of root inputs per backend, once as
a+band once as an in-placea+a. The low and high words matched independently computed 64-bit sums in all 64 readbacks on each backend. Forcing carry to zero first changed word 9 from 1 to 0. Forcing it to one or computing it after overwriting the low SGPR first changed word 1 from 0 to 1. Keeping the previous SCC after the high add first changed word 10 from 0 to 1. All three backends caught all four mutations.Removing the proof restored the original refusal on the positive fixture. Removing the branch-target guard wrongly accepted both forward and backward entries into the high add.
Evidence and follow-up
The source program, its LLVM encodings, independent expected words and refusal controls are in the existing compute test. This verifies the arithmetic slice independently of the waterfall-loop selection (T1) and per-lane descriptor binding (T3). The ten observed runtime programs still need those pieces.
Refs #2644.
AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:06:51Z.
Review: COMMENTED
Review of head
ef563d82(comment only).What I checked:
adjacent_address_carriesonly pairs a numerics_add_u32 sN, a, bwith an immediately followings_add_u32 sN+1, 0, src_sccthat is not a branch target (tools/startup/gfx2hlsl.py). Carry is computed from the expression before the low register is written, so an addend equal to the destination is handled. The reader is armed only when the low add really emits arithmetic. Lane-mask inputs and joined masks are refused.address-carrydispatch case in tests/startup_gfx2hlsl_compute_check.py compares WARP readback against an independent CPU reference (low word, high word, SCC, and a guard word). The refusal controls cover an intervening SCC writer, non-adjacent adds, a branch into the high add, elided descriptor arithmetic, a wrong high addend and a wrong high register.Commands run locally:
python3 -B tests/startup_gfx2hlsl_compute_check.py(pass)python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD(pass)ctest -R startup_gfx2hlsl_computeon dev and release: 29/29 each (WARP and the VM adapter); receipt follows in a separate comment.No blocking findings. This does not claim any game-startup result; fixture tests only.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:06:52Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
ef563d8214c47e551d09f7d82b57f7255eea7062:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):0.36s(configure0.00s)ctest --preset dev -R 'startup_gfx2hlsl_compute' --parallel 4 --no-tests=error --output-on-failure): 29/29 passed (4.93s:startup_gfx2hlsl_compute_mbcnt_warp0.84s,startup_gfx2hlsl_compute_mbcnt_hardware0.84s,startup_gfx2hlsl_compute_dropped-store_warp0.34s,startup_gfx2hlsl_compute_c-unpredicated_warp0.38s,startup_gfx2hlsl_compute_b-offset_warp0.39s,startup_gfx2hlsl_compute_dropped-store_hardware0.38s,startup_gfx2hlsl_compute_controls0.74s,startup_gfx2hlsl_compute_swapped-axes_hardware0.39s,startup_gfx2hlsl_compute_swapped-axes_warp0.38s,startup_gfx2hlsl_compute_c-unpredicated_hardware0.38s,startup_gfx2hlsl_compute_b-offset_hardware0.40s,startup_gfx2hlsl_compute_hardware3.10s,startup_gfx2hlsl_compute_warp3.10s,startup_gfx2hlsl_compute_g-overlap_warp0.39s,startup_gfx2hlsl_compute_m-else-unswitched_warp0.39s,startup_gfx2hlsl_compute_m-else-unswitched_hardware0.39s,startup_gfx2hlsl_compute_g-swapped-offsets_warp0.38s,startup_gfx2hlsl_compute_j-scalar-dropped_warp0.39s,startup_gfx2hlsl_compute_k-block-entered_warp0.40s,startup_gfx2hlsl_compute_f-peer_hardware0.42s,startup_gfx2hlsl_compute_j-scalar-dropped_hardware0.42s,startup_gfx2hlsl_compute_g-overlap_hardware0.39s,startup_gfx2hlsl_compute_k-block-entered_hardware0.41s,startup_gfx2hlsl_compute_h-inner-unpredicated_warp0.41s,startup_gfx2hlsl_compute_f-broadcast_hardware0.42s,startup_gfx2hlsl_compute_h-inner-unpredicated_hardware0.42s,startup_gfx2hlsl_compute_g-swapped-offsets_hardware0.41s,startup_gfx2hlsl_compute_f-broadcast_warp0.36s,startup_gfx2hlsl_compute_f-peer_warp0.38s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):4.94s(configure0.00s)ctest --preset release -R 'startup_gfx2hlsl_compute' --parallel 4 --no-tests=error --output-on-failure): 29/29 passed (5.03s:startup_gfx2hlsl_compute_mbcnt_hardware0.92s,startup_gfx2hlsl_compute_mbcnt_warp0.95s,startup_gfx2hlsl_compute_g-overlap_warp0.38s,startup_gfx2hlsl_compute_controls0.70s,startup_gfx2hlsl_compute_b-offset_warp0.41s,startup_gfx2hlsl_compute_swapped-axes_warp0.42s,startup_gfx2hlsl_compute_c-unpredicated_warp0.39s,startup_gfx2hlsl_compute_dropped-store_warp0.38s,startup_gfx2hlsl_compute_g-swapped-offsets_warp0.39s,startup_gfx2hlsl_compute_j-scalar-dropped_hardware0.38s,startup_gfx2hlsl_compute_k-block-entered_hardware0.40s,startup_gfx2hlsl_compute_hardware3.18s,startup_gfx2hlsl_compute_warp3.21s,startup_gfx2hlsl_compute_j-scalar-dropped_warp0.40s,startup_gfx2hlsl_compute_h-inner-unpredicated_warp0.40s,startup_gfx2hlsl_compute_g-overlap_hardware0.41s,startup_gfx2hlsl_compute_f-broadcast_hardware0.38s,startup_gfx2hlsl_compute_h-inner-unpredicated_hardware0.41s,startup_gfx2hlsl_compute_f-peer_hardware0.41s,startup_gfx2hlsl_compute_g-swapped-offsets_hardware0.40s,startup_gfx2hlsl_compute_c-unpredicated_hardware0.44s,startup_gfx2hlsl_compute_dropped-store_hardware0.42s,startup_gfx2hlsl_compute_swapped-axes_hardware0.42s,startup_gfx2hlsl_compute_f-peer_warp0.42s,startup_gfx2hlsl_compute_b-offset_hardware0.40s,startup_gfx2hlsl_compute_f-broadcast_warp0.38s,startup_gfx2hlsl_compute_k-block-entered_warp0.39s,startup_gfx2hlsl_compute_m-else-unswitched_warp0.38s,startup_gfx2hlsl_compute_m-else-unswitched_hardware0.38s)tests/mesh_heap_sampler_check.pyok (1.1s),tests/startup_buffer_address_check.pyok (0.8s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_image_store_check.pyok (1.1s),tests/startup_compute_image_store_d16_check.pyok (0.9s),tests/startup_compute_request_offline_check.pyok (0.9s),tests/startup_compute_store_format_xyzw_check.pyok (0.5s),tests/startup_compute_translate_check.pyok (0.4s),tests/startup_flat_param_check.pyok (0.3s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.8s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.3s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.2s),tests/startup_gfx2hlsl_capture_check.pyok (1.9s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.6s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.2s),tests/startup_gfx2hlsl_compute_check.pyok (0.8s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.3s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.4s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.5s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.5s),tests/startup_gfx2hlsl_f32_nan_check.pyok (9.5s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.2s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.1s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.3s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.2s),tests/startup_gfx2hlsl_interp_p2_hi_check.pyok (0.3s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.4s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.2s),tests/startup_gfx2hlsl_mask_data_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.2s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.6s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (4.6s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.3s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (0.9s),tests/startup_gfx2hlsl_root_check.pyok (1.1s),tests/startup_gfx2hlsl_s_abs_check.pyok (0.1s),tests/startup_gfx2hlsl_s_bitset_check.pyok (0.2s),tests/startup_gfx2hlsl_sad_check.pyok (0.4s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.4s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.4s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.3s),tests/startup_gfx2hlsl_shift64_check.pyok (0.3s),tests/startup_gfx2hlsl_sload_const_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (8.2s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.2s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.4s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (6.2s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.8s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.2s),tests/startup_image_gather_lz_check.pyok (0.6s),tests/startup_image_load_d16_check.pyok (1.0s),tests/startup_image_sample_a16_check.pyok (0.3s),tests/startup_image_sample_b_check.pyok (0.3s),tests/startup_image_sample_c_check.pyok (0.3s),tests/startup_image_sample_l_check.pyok (0.2s),tests/startup_image_sample_lod_check.pyok (0.8s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_loop_refusal_check.pyok (0.3s),tests/startup_mesh57_skeleton_check.pyok (1.0s),tests/startup_run_ps1_check.pyok (18.7s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (3.8s),tests/startup_smem_address_check.pyok (0.2s),tests/startup_stream_fetch_check.pyok (0.3s),tests/startup_stream_interface_check.pyok (0.3s),tests/startup_translator_check.pyok (0.6s)sccache: 24/53 hits; wall107.5sAI-assisted; commands listed were executed locally.