startup: lower scalar null operand and guard non-SGPR SALU destinations in gfx2hlsl #2690
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2698"
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 consolelogkyo on 2026-11-26T02:32:33Z.
Summary
Lowers the RDNA 2
nullscalar operand (code 125) and replacesreg_range(...)[1]TypeErrorcrashes on non-SGPR scalar destinations intools/startup/gfx2hlsl.pywith explicitUnsupportedrefusals:nullsource (code 125):Stage.u,Stage.const_u32,Stage.uniform_source,Stage.scalar_const,SCALAR_CONST_FOLD,scalar_bitset,op_s_bfm_b32, andVOP3_ONLY_VEC_UinStage.lowerreadnullas wave-uniform0x00000000u(per AMD RDNA 2 ISA §3.2 / Table 26: reads ofnullreturn0).nulldestination inStage.scalarandop_s_bfm_b32: plain 32-bit numeric/constant SALU writes tonulldiscard the destination register write while still emitting modeledSCCupdates (s_and_b32,s_or_b32,s_xor_b32,s_andn2_b32,s_orn2_b32,s_not_b32,s_nand_b32,s_nor_b32,s_xnor_b32,s_lshl_b32,s_lshr_b32,s_ashr_i32,s_bfe_u32,s_absdiff_i32) and leavingSCCuntouched on non-SCC operations (s_mov_b32,s_movk_i32,s_brev_b32,s_mul_i32,s_bfm_b32).s_lshl1..4_add_u32,PACK_B16/s_sext_*/s_mul_hi_*, ands_cselect_b32retain their pinnednulldestination refusals.Unsupportedrefusals replacingTypeError(#2618Erows):_b64operations (s_and_b64 null, exec, s[0:1],s_and_b64 null, s[0:1], s[2:3], etc.) and 32-bit lane-mask sources (exec_lo,vcc_lo, compare-mask SGPRs) intonullraise<op> into null on a lane maskor<op> into nullinstead ofTypeError(preserving soundness where wave-wide or 64-bitSCCdiffers from a single lane's low-word bit).SCC_UNMODELLEDoperations (s_add_u32,s_add_i32,s_sub_u32,s_sub_i32,s_min_*,s_max_*) intonullraise<op> into null: SCC is not modelledrather than silently dropping their carry/overflow/select flag.nulland unmodelled non-SGPR destinations (vcc_hi,exec_hi,ttmp*, plusvcc_lo/exec_loinop_s_bfm_b32) raise specificUnsupportedreasons instead ofTypeError.Refs #2618, #1723, #2463.
Verification
Added
tests/startup_gfx2hlsl_scalar_null_check.py(source-built synthetic encodings only; wired intoCMakeLists.txt,.github/workflows/windows.ymlfor Linuxllvm-mc-15+libLLVM-15.so.1and Linux Python checks,AGENTS.md, anddocs/experiments.md):startup_gfx2hlsl_scalar_null_controls: PASSED (14 32-bit SCC-writing SALU ops intonullacross boundary pairs reaching bothSCC=0andSCC=1, non-SCCnulldiscards,null-source constant folding +UNIFORM_VALUv_readfirstlane_b32+ComputePipeline, refusal sweep across all 48SCAops +s_bfm_b32onvcc_hi/exec_hi/ttmp0/null, and unlowered negative control).startup_gfx2hlsl_scalar_null_warp(Microsoft Basic Render Driver1414:008c, driver10.0.26100.9818,debug_layer=enabled,debug_errors=0 debug_warnings=0): PASSED (4 pixel draws acrossFXC ps_5_1+DXC ps_6_0+ 6 pixel mutations caught; 4 runtime root-constant SALUnull-destination +s_cbranch_scc0buffer readback runs + 4 HLSL mutations caught).startup_gfx2hlsl_scalar_null_hardware(AMD Radeon RX 9070 XT1002:7550, driver32.0.32029.2010,debug_layer=enabled,debug_errors=0 debug_warnings=0): PASSED (same 4 pixel draws + 6 pixel mutations + 4 root-constant runs + 4 HLSL mutations).startup_gfx2hlsl_*pure-Python suite,startup_translator,docs_links, andbidi_controls: PASSED.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:35:51Z.
Review: COMMENTED
Review of head
909082fb: no blocking findings.What I checked:
nullas a source reads as0uinStage.u,const_u32, the uniform test and the constant folder. As a destination, a 32-bit SALU op only updates SCC. 64-bit pairs, lane-mask sources and ops whose SCC is not modelled are refused.Unsupportedbeforereg_range(...)[1]is read. This covers the address-carrys_add_u32path and the descriptor-data path, so aTypeErrorcrash becomes a clean refusal.CMakeLists.txt,AGENTS.mdandwindows.yml.nulloperand in gfx2hlsl. #264 and #777 cover the disassembler and pixel_aot.Commands (Linux, on
909082fb):python3 tests/startup_gfx2hlsl_scalar_null_check.py: okpython3 tests/startup_gfx2hlsl_scalar_table_arity_check.py: 0 failedpython3 tests/startup_gfx2hlsl_compute_check.py: okpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleannulldestination. The check fails.nullsource as1uinstead of0u. The check fails. Both were reverted.The Win2025 dev + release run on this head is in progress. A receipt will follow.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:37:08Z.
Thanks for opening this, it answers the overlap I raised on #1723. We will not open a competing PR for the null operand or the non-SGPR destination guards; this one covers them.
We have one small extra piece we would like to add on top once this is merged: in wave32,
vcc_hiis not part of the lane mask, so a scalar write to it can be lowered as an ordinary scalar register instead of being refused. It stays refused when the program could run as wave64 and reads VCC as a mask. It will come as a separate Draft PR on top ofmain, with a WARP readback test, so this PR does not need to change.If you would rather fold that case into this PR yourself, just say so here and we will share the test words.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:39:02Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
909082fbd40af2af861520e1bd6a07fd8c3d88fd:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 2):4.15s(configure4.36s)ctest --preset dev -R '^startup_gfx2hlsl_(scalar_null|scalar_table_arity|compute)' --parallel 2 --no-tests=error --output-on-failure): 35/35 passed (14.20s:startup_gfx2hlsl_compute_warp3.78s,startup_gfx2hlsl_compute_hardware3.84s,startup_gfx2hlsl_compute_b-offset_hardware0.43s,startup_gfx2hlsl_compute_dropped-store_hardware0.45s,startup_gfx2hlsl_compute_dropped-store_warp0.42s,startup_gfx2hlsl_compute_c-unpredicated_warp0.46s,startup_gfx2hlsl_compute_c-unpredicated_hardware0.46s,startup_gfx2hlsl_compute_swapped-axes_warp0.45s,startup_gfx2hlsl_compute_swapped-axes_hardware0.43s,startup_gfx2hlsl_compute_b-offset_warp0.43s,startup_gfx2hlsl_compute_mbcnt_warp0.96s,startup_gfx2hlsl_compute_controls0.81s,startup_gfx2hlsl_compute_mbcnt_hardware1.02s,startup_gfx2hlsl_compute_f-peer_warp0.46s,startup_gfx2hlsl_compute_f-broadcast_warp0.39s,startup_gfx2hlsl_compute_f-broadcast_hardware0.41s,startup_gfx2hlsl_compute_k-block-entered_warp0.40s,startup_gfx2hlsl_compute_k-block-entered_hardware0.40s,startup_gfx2hlsl_compute_g-swapped-offsets_hardware0.40s,startup_gfx2hlsl_compute_h-inner-unpredicated_hardware0.41s,startup_gfx2hlsl_compute_h-inner-unpredicated_warp0.37s,startup_gfx2hlsl_compute_f-peer_hardware0.43s,startup_gfx2hlsl_compute_g-overlap_warp0.42s,startup_gfx2hlsl_compute_j-scalar-dropped_warp0.34s,startup_gfx2hlsl_compute_g-overlap_hardware0.40s,startup_gfx2hlsl_compute_g-swapped-offsets_warp0.39s,startup_gfx2hlsl_compute_j-scalar-dropped_hardware0.41s,startup_gfx2hlsl_scalar_table_arity0.53s,startup_gfx2hlsl_scalar_null_controls0.35s,startup_gfx2hlsl_scalar_null_warp2.87s,startup_gfx2hlsl_scalar_null_hardware2.81s,startup_gfx2hlsl_compute_m-else-unswitched_warp0.41s,startup_gfx2hlsl_compute_n-dropped-broadcast_warp0.38s,startup_gfx2hlsl_compute_m-else-unswitched_hardware0.34s,startup_gfx2hlsl_compute_n-dropped-broadcast_hardware0.40s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 2):14.22s(configure4.50s)ctest --preset release -R '^startup_gfx2hlsl_(scalar_null|scalar_table_arity|compute)' --parallel 2 --no-tests=error --output-on-failure): 35/35 passed (13.90s:startup_gfx2hlsl_compute_warp3.24s,startup_gfx2hlsl_compute_hardware3.37s,startup_gfx2hlsl_compute_dropped-store_hardware0.42s,startup_gfx2hlsl_compute_mbcnt_warp0.93s,startup_gfx2hlsl_compute_b-offset_warp0.42s,startup_gfx2hlsl_compute_swapped-axes_hardware0.42s,startup_gfx2hlsl_compute_c-unpredicated_warp0.42s,startup_gfx2hlsl_compute_b-offset_hardware0.43s,startup_gfx2hlsl_compute_dropped-store_warp0.43s,startup_gfx2hlsl_compute_c-unpredicated_hardware0.46s,startup_gfx2hlsl_compute_swapped-axes_warp0.40s,startup_gfx2hlsl_compute_controls0.81s,startup_gfx2hlsl_compute_h-inner-unpredicated_warp0.40s,startup_gfx2hlsl_compute_f-peer_warp0.41s,startup_gfx2hlsl_compute_mbcnt_hardware0.94s,startup_gfx2hlsl_compute_f-broadcast_warp0.43s,startup_gfx2hlsl_compute_g-swapped-offsets_hardware0.44s,startup_gfx2hlsl_compute_j-scalar-dropped_warp0.44s,startup_gfx2hlsl_compute_k-block-entered_warp0.42s,startup_gfx2hlsl_compute_g-overlap_warp0.43s,startup_gfx2hlsl_compute_g-swapped-offsets_warp0.40s,startup_gfx2hlsl_compute_k-block-entered_hardware0.43s,startup_gfx2hlsl_compute_f-broadcast_hardware0.39s,startup_gfx2hlsl_compute_g-overlap_hardware0.38s,startup_gfx2hlsl_compute_f-peer_hardware0.42s,startup_gfx2hlsl_compute_j-scalar-dropped_hardware0.44s,startup_gfx2hlsl_compute_h-inner-unpredicated_hardware0.43s,startup_gfx2hlsl_scalar_null_controls0.33s,startup_gfx2hlsl_scalar_table_arity0.57s,startup_gfx2hlsl_scalar_null_hardware2.90s,startup_gfx2hlsl_scalar_null_warp3.13s,startup_gfx2hlsl_compute_m-else-unswitched_warp0.44s,startup_gfx2hlsl_compute_n-dropped-broadcast_warp0.44s,startup_gfx2hlsl_compute_m-else-unswitched_hardware0.44s,startup_gfx2hlsl_compute_n-dropped-broadcast_hardware0.43s)tests/mesh_heap_sampler_check.pyok (1.4s),tests/startup_buffer_address_check.pyok (0.9s),tests/startup_buffer_format_word3_table_check.pyok (0.2s),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.4s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.4s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.2s),tests/startup_gfx2hlsl_capture_check.pyok (1.8s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.5s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.7s),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.3s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.4s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.1s),tests/startup_gfx2hlsl_f32_nan_check.pyok (8.5s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.2s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.2s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_heap_record_check.pyok (0.3s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.2s),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.4s),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.3s),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.0s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (1.0s),tests/startup_gfx2hlsl_root_check.pyok (1.1s),tests/startup_gfx2hlsl_s_abs_check.pyok (0.2s),tests/startup_gfx2hlsl_s_bitset_check.pyok (0.2s),tests/startup_gfx2hlsl_s_ff1_check.pyok (0.2s),tests/startup_gfx2hlsl_s_flbit_check.pyok (0.2s),tests/startup_gfx2hlsl_sad_check.pyok (0.5s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_null_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.5s),tests/startup_gfx2hlsl_sdwa_cndmask_check.pyok (0.3s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.4s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.2s),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.7s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.5s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.5s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (6.7s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (3.0s),tests/startup_image_2d_array_check.pyok (0.3s),tests/startup_image_3d_check.pyok (0.3s),tests/startup_image_gather_lz_check.pyok (0.9s),tests/startup_image_load_d16_check.pyok (1.6s),tests/startup_image_sample_a16_check.pyok (0.3s),tests/startup_image_sample_b_check.pyok (0.4s),tests/startup_image_sample_c_check.pyok (0.4s),tests/startup_image_sample_l_check.pyok (0.3s),tests/startup_image_sample_lod_check.pyok (1.0s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_depth_only_check.pyok (0.3s),tests/startup_mesh57_loop_refusal_check.pyok (0.2s),tests/startup_mesh57_skeleton_check.pyok (1.7s),tests/startup_run_ps1_check.pyok (15.9s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.3s),tests/startup_shader_cache_rekey_check.pyok (4.5s),tests/startup_smem_address_check.pyok (0.3s),tests/startup_stream_fetch_check.pyok (0.3s),tests/startup_stream_interface_check.pyok (0.4s),tests/startup_translator_check.pyok (0.8s)sccache: 13/20 hits; wall138.6sAI-assisted; commands listed were executed locally.