Skip to content

startup: gfx2hlsl refuses VOPC SDWA compares (v_cmp*_sdwa, v_cmpx*_sdwa) #1906

Backlog

Description

@MasterDomino

Part of #870. In a local startup run on current main (RX 9070 XT, the post-confirm load), tools/startup/gfx2hlsl.py --pending refuses 12 pipeline requests with unsupported: v_cmpx_le_i32_sdwa. compare() rejects every compare with an _sdwa suffix. tools/disasm_rdna2.py already decodes VOPC SDWA in full (_decode_vopc_sdwa), and pixel_aot lowers only the f32 form with DWORD selects.

Forms in those refused pixel programs. Aggregate count per form, with operands reduced to their kind:

Count Form
12 v_cmpx_le_i32_sdwa <const>, sext(vN) src0_sel:DWORD src1_sel:BYTE_0
3 v_cmpx_ne_i32_sdwa sN, vN src0_sel:DWORD src1_sel:BYTE_0
9 v_cmp_ne_i32_sdwa sN, sN, vN src0_sel:DWORD src1_sel:BYTE_0
12 v_cmpx_class_f32_sdwa <const>, vN src0_sel:DWORD src1_sel:BYTE_1
39 v_cmp_class_f32_sdwa sN, <const or sN>, vN src0_sel:DWORD src1_sel:BYTE_1 or WORD_1

The translator stops at the first refusal, so the later forms in the same programs are hidden today. The _class_ forms also need v_cmp_class_f32 itself, which compare() has no condition for (6 separate refusals in the same run). I'd keep that as its own follow-up.

Proposed scope

compare() accepts the _sdwa forms of the existing compare table:

  • Operand selects: i32/u32 sources take src0_sel/src1_sel through the existing sdwa_source helper, with sext() when printed.
  • f32 sources: keep DWORD selects only and refuse any other select.
  • Destination: EXEC for v_cmpx_*_sdwa (gfx10 forbids sdst_en there); VCC, or the SGPR pair the decoder prints, for v_cmp_*_sdwa. Same EXEC masking as the non-SDWA path.
  • Refused: class, float sources with a non-DWORD select, and any SDWA modifier the decoder does not print for compares.

Acceptance

  • Translator check against a reference (in the style of startup_gfx2hlsl_sdwa_check.py). Every compare in the table × every select × sext on/off, with the source chosen so the selected field differs from the full DWORD. The result must equal an integer reference: the selected, extended field compared as the type says. This covers v_cmp into VCC and into an SGPR pair, and v_cmpx into EXEC.
  • LLVM 15 round trip: encode and decode for the accepted forms.
  • Refusal cases: class, a non-DWORD select on an f32 compare, and an unexpected modifier.
  • Draw on WARP and the RX 9070 XT: a source-built pixel program where a v_cmpx_le_i32_sdwa on a sign-extended byte decides which pixels survive, checked pixel by pixel.
  • Negative controls: a translation that ignores the select, and one that ignores sext, must both fail the draw.
  • Recount on our loading path: report the same run's refusal counts again, aggregate only.

I'd like to take this; PR to follow.

AI-assisted.

Activity

  1. MasterDomino commented on Nov 24, 2026

    @MasterDomino
    CollaboratorAuthor

    PR: #1915. Reference check over every integer compare × destination × select × sext (9,408 forms × 64 value pairs) plus the f32 DWORD forms and the refusals; LLVM 15 decode of all 9,889 accepted forms; a source-built draw where v_cmpx_le_i32_sdwa on a sign-extended byte decides which pixels survive — 256/256 on WARP and the RX 9070 XT with FXC and DXC, and the select-dropping and sext-dropping mutants fail (120 and 96 pixels). The llvm-mc encode mode runs in the CI LLVM 15 job (no llvm-mc locally). Recount on our loading path: the 12 requests now get past this refusal and stop at the next gap (s_nor_b32); class compares remain the follow-up.

    AI-assisted.

  2. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    The integer-only lowering in #1915 has merged. On the exact candidate the independent translator run passed 9,408 integer forms over 64 value pairs and refused all 720 f32 SDWA forms. The author reported that the 12 loading requests advanced to the next shader refusal, s_nor_b32. That result is a shader translation checkpoint. The main executable's measured slot 148 startup boundary is unchanged.

    Keep float SDWA on this issue pending the independent predicate work in #1920. The scalar complement follow-up is already claimed in #1919.

  3. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    #1969 is on main at 9dcf1ae. The binary32 class compare now selects the class mask from SRC1. Independent default FXC and DXC runs matched all 256 pixels on WARP and RTX 4060 Laptop, and bypassing the selector failed the class control. The ordinary f32 comparison predicates are still tracked here.

  4. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    CollaboratorAuthor

    I'd like to take the f32 SDWA compares in gfx2hlsl that #1915 left refused. Now that #1930 and #1949 are on main, every f32 predicate in the table is exact on NaN under default-flag FXC and DXC, so the SDWA forms can reuse it.

    Scope:

    • v_cmp_*_f32_sdwa and v_cmpx_*_f32_sdwa with src0_sel/src1_sel and the SDWA neg/abs source modifiers.
    • A selected word or half reads as binary32 bits after the selection, as the ISA defines for SDWA. Each selection and modifier is checked against llvm-mc and LLVM's disassembler.
    • v_cmp_class_f32_sdwa stays out of scope; startup: add the SDWA forms of v_cmp_class_f16 in gfx2hlsl #2020 covers the f16 class forms.

    Tests:

    AI-assisted.

  5. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    CollaboratorAuthor

    PR: #2212 (Refs #1906). It is narrower than my claim and corrects its semantics wording.

    • DWORD selections are lowered: src0_sel:DWORD src1_sel:DWORD, with any neg/abs, emits exactly the e64 text, including the startup: lower gfx2hlsl f32 lg/nlg compares as ordered #1930/startup: keep gfx2hlsl f32 n-forms, o and u exact under FXC and DXC #1949 NaN bit test on the registers. That covers 720 forms, checked over the 256 NaN/denormal pairs under IEEE, FXC-rewrite and DXC-fold models, and drawn with default-flag FXC and DXC on WARP and the RX 9070 XT.
    • Byte and word selections are refused, with the message f32 SDWA byte/word selection depends on the binary32 denormal mode. That's all 34,560 such forms. My claim said a selected field "reads as binary32 bits ... as the ISA defines". The RDNA 2 ISA guide defines only the SDWAB fields, and the zero-extend-then-read-as-binary32 model comes from LLVM's SIPeepholeSDWA. Under that model, the field is always +0 or a denormal, so the result depends only on the denormal mode, which gfx2hlsl doesn't read. pixel_aot refuses the same forms.
    • Still refused: sext() on a float source (integer-only; LLVM 15 doesn't decode it), clamp/omod/dst_sel, and the class compares.

    AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions