startup: refuse a VOPC compare into a non-SGPR destination in gfx2hlsl #2310
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2310
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2310/head"
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?
@denn0x on GitHub · 2026-11-25 11:40 UTC · original
denn0x:startup/compare-dst-refusal→main· +90 −1 · 5 files · 1 commits · merged 2026-11-25 11:49 UTCWhat
The e64 (VOP3) form of a VOPC compare names its scalar destination. In
tools/startup/gfx2hlsl.pythe generic compare path handledexec/exec_loandvcc/vcc_lo, then tookreg_range(dst)[1]for anything else. Forvcc_hi,exec_hiorm0,reg_rangereturnsNone, so theTypeErrorended the whole translation instead of refusing one instruction.The destination is now checked the same way the class-compare path and the
v_add_co_u32carry-out already check theirs. It is refused as<op> into <dst>. Every accepted form emits the same lines as before.Test
tests/startup_gfx2hlsl_compare_dst_check.py(new). It is registered in CMake asstartup_gfx2hlsl_compare_dst_controls, in the Python CI job and in AGENTS.md.v_cmp_lt_u32_e64,v_cmp_eq_i32_e64,v_cmp_gt_f32_e64andv_cmp_neq_f32_e64intovcc_hi,exec_hiandm0must raisegfx2hlsl.Unsupportednaming the destination, not another exception.s20: lowered, ands20is marked as a lane mask;vcc_lo: writesvcc;exec_lo: writesexec.On
mainwithout the change, the 12 refusal cases fail withTypeError: 'NoneType' object is not subscriptable.tests/startup_gfx2hlsl_*_check.py,tests/startup_image_*_check.py,startup_translator_check.pyandstartup_flat_param_check.pypasses on this branch.allbuilds (Ninja Release, MSVC Build Tools 18, Windows 11). Device-free, so there were no GPU runs and no capability skips.@tedin7 on GitHub · 2026-11-25 11:45 UTC · original · reviewed
Review of head
f3b4d7e5b1295d9fb7fa9961836474ac84e7b54c(comment only).Verdict: no P1, no P2. Logic is correct; one test-coverage nit.
Checked:
/O2and chart jobs are skipped. Mergeable, title neutral, no clean-room concerns in the diff.tools/startup/gfx2hlsl.py:3365-3372: the new guard (reg = reg_range(dst); if not reg or reg[0] != 's': raise Unsupported(...)) is identical to the class-compare path at:3304-3307. Theexec/exec_loandvcc/vcc_lobranches are untouched, so accepted forms emit the same lines.reg_rangereturnsNoneforvcc_hi,m0andttmp0, so those used to hitTypeErrorand now refuse.startup_gfx2hlsl_compare_dst_controls, the Python CI job, and the AGENTS.md list.Commands run locally in a worktree at this head:
python3 -B tests/startup_gfx2hlsl_compare_dst_check.py->compare destination checks: 0 failedstartup_gfx2hlsl_add_sub_co_check.py,cselect_mask_check.py,mask_overwrite_check.py,startup_translator_check.py-> all pass (translator:0 failed)python3 tests/docs_links_check.py->Checked 18 Markdown files and 446 links.python3 tests/bidi_controls_check.py-> no bidirectional controlsgit diff --check origin/main...HEAD-> cleanmainversion ofgfx2hlsl.py->compare destination checks: 12 failed(the refusal cases are killed, as the PR says).if not reg:(drop thereg[0] != 's'kind check) -> test still0 failed. This mutant survives.Findings:
tests/startup_gfx2hlsl_compare_dst_check.py: no case where the destination is a VGPR.reg_range('v3')returns('v', 3, 3), so only thereg[0] != 's'half of the guard rejects it. Without that half,v_cmp_*_e64 v3, ...would be lowered as an SGPR write to index 3 and marked as a mask. Adding one refusal row (for examplev_cmp_lt_u32_e64 v3, ...) would pin it. Not blocking.AI-assisted; commands listed were executed locally.