startup: lower v_cvt_pk_u16_u32 and v_cvt_pk_i16_i32 in gfx2hlsl #2581
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2589"
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-25T22:13:09Z.
Summary
Lowers the VOP3A-only 32-to-16-bit saturating integer pack pair (
v_cvt_pk_u16_u32,0x36aandv_cvt_pk_i16_i32,0x36b) intools/startup/gfx2hlsl.py, matching the RDNA 2 ISA saturation bounds ([0, 65535]unsigned,[-32768, 32767]signed,S0in[15:0],S1in[31:16]) and thepixel_aotlowering from #779:VEC_Ulowering:v_cvt_pk_u16_u32:min({0}, 0xffffu) | (min({1}, 0xffffu) << 16u)v_cvt_pk_i16_i32:(asuint(clamp(asint({0}), -32768, 32767)) & 0xffffu) | (asuint(clamp(asint({1}), -32768, 32767)) << 16u)s0..s105), 32-bit inline constants, and 32-bit literals acrossPipelineandComputePipeline(including explicit_e64spelling), tracks scalar uniformity inUNIFORM_VALUforv_readfirstlane_b32, requires whole-32-bit source definitions (low16_only=False), and clearslow16_only_von destination VGPR writes.check_encodingrefuses VOP3A sourceabs(w0[10:8]),neg(w1[31:29], including on inline constants), and non-zero unusedsrc2(w1[26:18]) on the raw words before disassembly;Stagerefusesclamp,omod,op_sel, printed|vN|/-vNmodifiers, lane-mask sources (vcc_lo,exec_lo), non-VOP3 spellings (_e32,_sdwa,_dpp), and invalid operand counts or widths.Part of #1723.
Verification
Added
tests/startup_gfx2hlsl_cvt_pk_int16_check.py(source-built synthetic VOP3A words only; wired intoCMakeLists.txt,.github/workflows/windows.ymlfor Linuxllvm-mc-15+libLLVM-15.so.1and Windows WARP,AGENTS.md, anddocs/experiments.md):startup_gfx2hlsl_cvt_pk_int16_controls: PASSED (676(S0, S1)boundary pairs per opcode against independent ISA saturation references,ComputePipeline,_e64spelling,exec-masked emission,UNIFORM_VALU+low16_only_vprovenance, per-slotabs/neg/src2raw-word refusal reason checks,Stagerefusal controls, and unloweredVEC_Uremoval control).startup_gfx2hlsl_cvt_pk_int16_warp(Microsoft Basic Render Driver1414:008c, driver10.0.26100.9818,debug_layer=enabled,debug_errors=0 debug_warnings=0, FXCps_5_1+ DXCps_6_0): PASSED (16good draws matched,16mutated draws acrosstrunc_lo,trunc_hi,swap_halves, and opposite-signedness clamp matched their mutated words).startup_gfx2hlsl_cvt_pk_int16_hardware(AMD Radeon RX 9070 XT1002:7550, driver32.0.32029.2010,debug_layer=enabled,debug_errors=0 debug_warnings=0, FXCps_5_1+ DXCps_6_0): PASSED (16good draws matched,16mutated draws matched their mutated words).startup_gfx2hlsl_*pure-Python suite (84/84),startup_translator,docs_links, andbidi_controls: PASSED.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:17:00Z.
Review: COMMENTED
Review of head
3ca94fe8(comment only, no merge decision yet).What I checked:
v_cvt_pk_u16_u32=min(s0,0xffff) | min(s1,0xffff)<<16;v_cvt_pk_i16_i32clamps to [-32768, 32767] per half, low half masked. Matches the ISA bounds and thepixel_aotlowering._e32, SDWA, DPP, clamp/omod/op_sel, lane-mask sources and bad operands refused; the two ops added toUNIFORM_VALU..github/workflows/windows.yml(binary + decode + Linux list),CMakeLists.txt(controls + warp/hardware draw),AGENTS.mdanddocs/experiments.mdall extended. No other open or merged PR covers these two opcodes.Commands run locally:
python3 -B tests/startup_gfx2hlsl_cvt_pk_int16_check.py-> passpython3 tests/docs_links_check.py-> passpython3 tests/bidi_controls_check.py-> passgit diff --check origin/main...HEAD-> cleanNo blocking findings. Windows CI and a Win2025 WARP run on the head are still pending.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:36:34Z.
Review: COMMENTED
Review of head
b2022ed6(after the conflict resolution), against origin/main.Scope checked:
v_cvt_pk_u16_u32/v_cvt_pk_i16_i32lowering intools/startup/gfx2hlsl.py, the encoding guard, the Stage refusals, CMake/CI wiring, docs._e32, SDWA and DPP spellings are refused.is_lane_masknow usesgetattr(self, 'masks', ()), which is a safe fallback and does not change the existing behavior.CMakeLists.txt(controls + warp + hardware),windows.yml(binary and decode),docs/experiments.md,AGENTS.mdlist.Commands run locally (Linux):
python3 -B tests/startup_gfx2hlsl_cvt_pk_int16_check.py-> Self-test passedpython3 tests/docs_links_check.py-> ok (19 files, 499 links)python3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> clean0xffffu->0xfffeu-> the boundary-pair check fails.0x1ff->0x0-> the test fails with "accepted binary VOP3A with src2=1".No blocking findings. The WARP/hardware draws are not run on Linux; they run in the Windows CI job and in the Win2025 run.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:24:42Z.
Win2025 WARP receipt for head
3ca94fe8.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
3ca94fe8a78b06070c89f0269b6c39e231a526d4:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):1.23s(configure4.51s)ctest --preset dev -R 'startup_gfx2hlsl_cvt_pk_int16' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (5.82s:startup_gfx2hlsl_cvt_pk_int16_controls0.53s,startup_gfx2hlsl_cvt_pk_int16_warp5.44s,startup_gfx2hlsl_cvt_pk_int16_hardware5.06s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):5.84s(configure4.30s)ctest --preset release -R 'startup_gfx2hlsl_cvt_pk_int16' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (6.71s:startup_gfx2hlsl_cvt_pk_int16_controls0.46s,startup_gfx2hlsl_cvt_pk_int16_hardware5.86s,startup_gfx2hlsl_cvt_pk_int16_warp6.48s)tests/mesh_heap_sampler_check.pyok (0.8s),tests/startup_buffer_address_check.pyok (0.6s),tests/startup_buffer_format_word3_table_check.pyok (0.1s),tests/startup_compute_request_offline_check.pyok (0.6s),tests/startup_compute_translate_check.pyok (0.3s),tests/startup_flat_param_check.pyok (0.1s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (0.8s),tests/startup_gfx2hlsl_capture_check.pyok (1.3s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.4s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.6s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),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.5s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.4s),tests/startup_gfx2hlsl_f32_nan_check.pyok (7.1s),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.2s),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_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.4s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (3.1s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.1s),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_sad_check.pyok (0.5s),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.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.1s),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.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.8s),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.3s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (5.1s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.1s),tests/startup_gfx2hlsl_watch_check.pyok (2.7s),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.6s),tests/startup_image_load_d16_check.pyok (1.0s),tests/startup_image_sample_a16_check.pyok (0.2s),tests/startup_image_sample_b_check.pyok (0.2s),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.7s),tests/startup_inline_sampler_check.pyok (0.2s),tests/startup_mesh57_skeleton_check.pyok (0.4s),tests/startup_run_ps1_check.pyok (15.9s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (3.3s),tests/startup_smem_address_check.pyok (0.2s),tests/startup_stream_fetch_check.pyok (0.3s),tests/startup_stream_interface_check.pyok (0.4s),tests/startup_translator_check.pyok (0.7s)sccache: 17/92 hits; wall106.2sAI-assisted; commands listed were executed locally.