startup: refuse a lane mask read as data by v_mov_b32 and v_cndmask_b32 (Part of #1723) #2615
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2623"
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 Leyukaka on 2026-11-25T23:29:44Z.
Part of #1723 (claim).
A lane-mask register is a compare result in an SGPR,
vcc_lo,exec_loor a saved EXEC copy. In the one-lane model it holds only the current lane's bit, while RDNA 2 reads the whole mask word when the register is a data operand.op_v_cndmask_b32read both data operands throughu_src, andv_mov_b32read its source throughu()(plain, e64, and the SDWA form withsrc0_sel:DWORD), so both emitted the lane bit. Example: afterv_cmp_eq_u32_e64 s[30:31], 0, v0,v_cndmask_b32_e64 v1, 0, s30, s[30:31]gave 1 where the guest reads0xffffffffwhen all 32 lanes pass the compare.|s30|in #2439 and #2449 inherits the same value.This refuses a lane-mask register as a data source of
v_cndmask_b32(e32 and e64, both data operands) and ofv_mov_b32withv_mov_b32 data operand <src> is a lane mask, after stripping-,|..|,neg(),abs()andsext(). The lane-select operand ofv_cndmaskis unchanged.Not covered: other VALU data sources are unchanged. The generic VEC_U / VEC_F paths still read a mask SGPR through
u()(for examplev_or_b32 v1, s30, v0); onlyVOP3_ONLY_VEC_Uchecks. #2391 edits the same SDWAv_mov_b32line, so whichever merges second will need a small rebase, and its SDWAv_cndmaskbranch would want the same data-operand check.Existing tests whose expectations change:
startup_gfx2hlsl_readfirstlane_uniform_check: six refused cases move a mask withv_mov_b32before the read. They now stop there, and the expected text follows.startup_gfx2hlsl_add_sub_co_check: moving the carry-out SGPR as data is now the refusal checked.startup_gfx2hlsl_join_symbols_check: the exec-join reads usev_cndmask_b32_e64 v0, 0, 1, s16(the mask as the select), so they still reach the join logic; a plainv_mov_b32 v0, s16is checked to be refused.startup_gfx2hlsl_compute_check(check_descriptor_scc): the reader of the descriptor-derived SCC is now a lane select ons20instead of a move, so every variant still ends atscc from descriptor data. The SCC branches skip both dwords of the select.startup_gfx2hlsl_sdwa_check: "v_mov whole lane mask is the plain move" becomes "v_mov whole lane mask refused".Tests (Windows 11, Python 3.14), on main
66026a3plus this commit:python -B tests/startup_gfx2hlsl_mask_data_check.py(new): 10 refusals (s30,-s30,|s30|,neg(abs(s30)),vcc_loasv_cndmaskdata;v_mov_b32ofs30,exec_lo,vcc_lo, and SDWA DWORD ofs30andsext(s30)) and 3 accepted controls (the mask only as the select, a plain SGPR as data).startup_gfx2hlsl_compute_check,startup_gfx2hlsl_sdwa_check,startup_gfx2hlsl_readfirstlane_uniform_check,startup_gfx2hlsl_join_symbols_check,startup_gfx2hlsl_add_sub_co_check,startup_translator_check,startup_gfx2hlsl_refusals_check,startup_gfx2hlsl_cselect_mask_check,startup_gfx2hlsl_mask_overwrite_check,docs_links_check,bidi_controls_check.cmake --preset releaseconfigures and registersstartup_gfx2hlsl_mask_data_controls.Mutation checks, run by hand: dropping the
v_cndmaskcheck, dropping thev_mov_b32check, or not stripping|..|each makesstartup_gfx2hlsl_mask_data_checkfail. Dropping thev_mov_b32check also failsstartup_gfx2hlsl_readfirstlane_uniform_check.Measured on a local capture (counts only, inputs private) at main
fc97ade: 194 pipelines translate with and without this change; the new refusal is the first refusal of 1 request.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:31:57Z.
Review: COMMENTED
Review of head
8d886023against current main (comment only).Result: no blocking findings.
What I checked
reject_lane_mask_datastrips-,|..|,abs(),neg(),sext()and then refuses a lane-mask register. It is called fromop_v_mov_b32, fromv_cndmask_b32on both data operands, and from the SDWAsrc0_sel:DWORDv_mov_b32path. The lane-select operand is untouched.scc from descriptor data).CMakeLists.txtand.github/workflows/windows.ymlboth list the newstartup_gfx2hlsl_mask_data_check.py, next to its sibling mask checks.Commands run (Linux, clean worktree at the head)
python3 -B tests/startup_gfx2hlsl_{mask_data,compute,sdwa,readfirstlane_uniform,join_symbols,add_sub_co,refusals,cselect_mask,mask_overwrite}_check.py: all exit 0python3 -B tests/startup_translator_check.py: okpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleanv_cndmask_b32data check withpass: new test fails (exit 1).v_mov_b32data check withpass: new test fails (exit 1).Notes (not blockers)
VEC_U/VEC_Fgeneric paths (for examplev_or_b32 v1, s30, v0) still read the mask throughu().v_mov_b32line, so the second PR to merge needs a small update.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:35:53Z.
Win2025 WARP receipt for head
8d886023.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
8d886023c68ffbc28e6a8728d29ba11f05387587:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):1.88s(configure3.24s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):1.02s(configure2.26s)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.2s),tests/startup_compute_image_store_check.pyok (0.9s),tests/startup_compute_image_store_d16_check.pyok (0.7s),tests/startup_compute_request_offline_check.pyok (0.6s),tests/startup_compute_store_format_xyzw_check.pyok (0.3s),tests/startup_compute_translate_check.pyok (0.2s),tests/startup_flat_param_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.7s),tests/startup_gfx2hlsl_capture_check.pyok (0.9s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.4s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.1s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.2s),tests/startup_gfx2hlsl_f32_nan_check.pyok (4.5s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.1s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.1s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.1s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.1s),tests/startup_gfx2hlsl_interp_p2_hi_check.pyok (0.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.2s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_data_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.3s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (2.4s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.1s),tests/startup_gfx2hlsl_refusals_check.pyok (0.5s),tests/startup_gfx2hlsl_root_check.pyok (0.7s),tests/startup_gfx2hlsl_sad_check.pyok (0.3s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.3s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.2s),tests/startup_gfx2hlsl_shift64_check.pyok (0.2s),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 (7.5s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.5s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.3s),tests/startup_gfx2hlsl_swap_check.pyok (0.5s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (6.8s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.9s),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.5s),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.3s),tests/startup_image_sample_lod_check.pyok (0.9s),tests/startup_inline_sampler_check.pyok (0.3s),tests/startup_mesh57_skeleton_check.pyok (0.6s),tests/startup_run_ps1_check.pyok (14.0s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (2.7s),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: 92/134 hits; wall81.2sAI-assisted; commands listed were executed locally.