startup: refuse NEG on an inline-integer or literal VOP3 source in gfx2hlsl #2521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2529"
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 Makto94 on 2026-11-25T20:10:04Z.
Refs #1723
Problem
tools/startup/gfx2hlsl.pytranslates the text printed by the disassembler. For a VOP3 source, the disassembler prints inline integer 1 with the NEG bit set as-1. This is the same text as the plain inline -1 (operand 193). The two encodings therefore translate to the same0xffffffff. A literal 5 with NEG reads0xfffffffb. Float operations are affected too:v_cmp_lt_f32_e64with inline 1 and NEG translates toF(0xffffffffu).check_encodingalready notes this ("The printed -1 is ambiguous"). The only NEG model for an integer source in the repository isv_cndmask_b32(sign bit flipped). The hardware behavior of NEG on integer sources was not measured. Related guards: #2369 (raw-word check of NEG/ABS for the 16-bit compares), #2426 and #2450 (v_sad_*).Change
check_encodingreads word 1 of every VOP3 instruction. It refuses NEG (bits 31:29, one bit per source) on a source field in 128..192 (inline 0..64) or 255 (literal). The refusal names the opcode and the source slot.v_cndmask_b32_e64are excepted. They keep their sign-bit model.v_sad_*) keep their own refusal text. A few other refusals, for exampleop_selon a VOP3b form withsdsts105/s106, now report the new message because this rule fires first. They stay refusals.sdsts4/s105/s106 are unchanged. Unused source slots that carry NEG are also refused (conservative).docs/experiments.mdgets one paragraph in the section "Startup translator: 16-bit integer compares". It records the refusal, thev_cndmask_b32_e64exception and that the hardware behavior is not measured.Tests
tests/startup_gfx2hlsl_refusals_check.py, newcheck_neg_integer_sources:v_cndmask_b32_e64data slots. The test accepts as a valid refusal either the new message or an earlier NEG/ABS refusal of an existing guard (16-bit compares,v_sad_*from #2450).v_mad_u32_u24in all three slots (with NEG refused, without NEG translated), inline 0 and 64, a literal with and without NEG,v_add_f32_e64, a compare, a compare with a literal in slot 1,v_add_co_u32andv_lshlrev_b64.0xffffffff; inline -1 with NEG, inline floats 240..248 with NEG, andv_add_co_u32withsdsts4 are not refused by this rule;v_cndmask_b32_e64slots 0 and 1 with inline 1 and NEG still give0x80000001u; its mask slot (slot 2) is refused.Before: on base
c133432awith only the new test, the check fails (rc=1, 12 controls failed). After: with this change it passes (rc=0, 82 controls ok).Mutation checks
Independent falsification (on the same two commits at base
c133432a; the rebase ontod6830702applied without changes, and the three checks and the full Python list were rerun ond6830702). Each mutant was applied in a temporary copy. All were killed.startup_gfx2hlsl_refusals_check.py(6 controls)startup_gfx2hlsl_refusals_check.py(2 controls)startup_gfx2hlsl_refusals_check.py(1 control)v_cndmask_b32_e64exception extended to slot 2startup_gfx2hlsl_refusals_check.py(3 controls)v_add_f32_e64startup_gfx2hlsl_refusals_check.py(3 controls)v_mul_i32_i24_e64startup_gfx2hlsl_refusals_check.py(2 controls)v_mad_i32_i24startup_gfx2hlsl_refusals_check.py(2 controls)<op> with neg/absstartup_gfx2hlsl_refusals_check.py(12 controls)startup_gfx2hlsl_refusals_check.py(6 controls)startup_gfx2hlsl_cmp16_check.pyIndependent falsification also ran a differential of
main(c133432a) against this change over 608256 VOP3 words: opcode 0..0x3ff, 3 source slots, 22 source values, NEG in {0, slot bit, 7},sdstin {4, 105, 106}.v_cndmask_b32_e64data slots.op_selon a VOP3b form withsdsts105/s106).v_sad_*is unchanged.v_mul_i32_i24_e64andv_mad_i32_i24(#2410) are covered without a list of names.Verification
Base
d6830702; commits under testbd66f8fb(code and test) and38b5464e(docs). Windows 11 build 26300, Python fromout/pe-env.d6830702, viatools/run_checks_parallel.py): no FAILED. The only non-ok results arestartup_run_sh_check.pyandstartup_build_rev_check.py, which return 77 (capability skip) on the base as well. A skip is not a pass.Limits
check_encodingoru_srcforv_cndmask_b32, and #2475 touchestools/startup/gfx2hlsl.py; a rebase may be needed.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:11:57Z.
Review: COMMENTED
Review of head
38b5464e(comment only).Scope: refusal-only guard in
check_encoding(tools/startup/gfx2hlsl.py), a new test intests/startup_gfx2hlsl_refusals_check.py, one docs paragraph. No new lowering, no executable-path change, no startup claim to verify on the game.Checked:
check_encodingalready names (printed-1for inline 1 with NEG vs. plain inline -1).v_cndmask_b32_e64data slots (0 and 1) keep their sign-bit model from #1710. Slot 2 is still refused.v_sad_*) still win with their own text where they fire first. The test accepts either message.Commands run locally (worktree on the exact head, 1 commit behind main):
python3 tests/startup_gfx2hlsl_refusals_check.py: PASSpython3 tests/docs_links_check.py: PASSpython3 tests/bidi_controls_check.py: PASSgit diff --check origin/main...HEAD: cleanv_cndmask_b32_e64exception: the test fails (exit 1).Result: no blocking findings. Win2025 WARP and the CI run on this head are still pending; merge stays gated on those.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:21:15Z.
Win2025 WARP receipt for head
d239d8e4after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
d239d8e492c9ca89153a3ac5c8a5ac94f0ebb5d6:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):32.16s(configure2.08s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):58.26s(configure2.08s)tests/mesh_heap_sampler_check.pyok (0.7s),tests/startup_buffer_address_check.pyok (0.5s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.5s),tests/startup_compute_translate_check.pyok (0.2s),tests/startup_flat_param_check.pyok (0.1s),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 (1.0s),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.1s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.2s),tests/startup_gfx2hlsl_f32_nan_check.pyok (5.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_join_symbols_check.pyok (0.2s),tests/startup_gfx2hlsl_loop_constants_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.6s),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.1s),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.1s),tests/startup_gfx2hlsl_shift64_check.pyok (0.1s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (5.3s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (0.8s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.1s),tests/startup_gfx2hlsl_swap_check.pyok (0.3s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (4.0s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.4s),tests/startup_image_2d_array_check.pyok (0.2s),tests/startup_image_3d_check.pyok (0.1s),tests/startup_image_gather_lz_check.pyok (0.7s),tests/startup_image_load_d16_check.pyok (0.8s),tests/startup_image_sample_a16_check.pyok (0.1s),tests/startup_image_sample_b_check.pyok (0.1s),tests/startup_image_sample_c_check.pyok (0.2s),tests/startup_image_sample_l_check.pyok (0.2s),tests/startup_image_sample_lod_check.pyok (0.6s),tests/startup_inline_sampler_check.pyok (0.1s),tests/startup_mesh57_skeleton_check.pyok (0.1s),tests/startup_run_ps1_check.pyok (9.3s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.1s),tests/startup_shader_cache_rekey_check.pyok (1.7s),tests/startup_smem_address_check.pyok (0.1s),tests/startup_stream_fetch_check.pyok (0.2s),tests/startup_stream_interface_check.pyok (0.2s),tests/startup_translator_check.pyok (0.4s)sccache: -734/-2529 hits; wall148.7sAI-assisted; commands listed were executed locally.