startup: lower binary32 class SDWA compares #1962

Merged
avt0m4t48 merged 1 commit from upstream-pr/1969 into main 2026-11-24 22:37:12 +00:00
avt0m4t48 commented 2026-11-24 22:17:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by avt0m4t48 on 2026-11-24T22:17:29Z.


Refs #1906. Lower v_cmp_class_f32_sdwa and v_cmpx_class_f32_sdwa when the float value uses SRC0_SEL:DWORD. Read the class mask through SRC1's byte, word or dword selector with optional sign extension. Reuse the existing class helper and EXEC rules. The regular floating-point comparison predicates stay in their separate follow-ups.

python3 -B tests/startup_gfx2hlsl_vopc_sdwa_check.py reproduced the refusal on the old lowering and now passes 42 class forms across all ten classes and both lane states. LLVM 15 round-tripped 9,931 VOPC SDWA forms and both encoded pixel fixtures. The existing classifier still matches its independent reference on 68,626 source patterns. Documentation and bidi checks passed.

ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa_warp$' -V passed on the Windows Server 2025 runner with WARP (Microsoft Basic Render Driver 10.0.26100.33648, debug layer enabled). Default FXC and DXC builds both matched all 256 pixels. Dropping the mask select failed against the reference and matched the separate whole-dword image. Physical GPU and title results remain unverified. WARP verification

Source-built inputs only. AI-assisted using Codex.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592519211 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1969). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T22:17:29Z. --- Refs #1906. Lower `v_cmp_class_f32_sdwa` and `v_cmpx_class_f32_sdwa` when the float value uses `SRC0_SEL:DWORD`. Read the class mask through SRC1's byte, word or dword selector with optional sign extension. Reuse the existing class helper and EXEC rules. The regular floating-point comparison predicates stay in their separate follow-ups. `python3 -B tests/startup_gfx2hlsl_vopc_sdwa_check.py` reproduced the refusal on the old lowering and now passes 42 class forms across all ten classes and both lane states. LLVM 15 round-tripped 9,931 VOPC SDWA forms and both encoded pixel fixtures. The existing classifier still matches its independent reference on 68,626 source patterns. Documentation and bidi checks passed. `ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa_warp$' -V` passed on the Windows Server 2025 runner with WARP (Microsoft Basic Render Driver 10.0.26100.33648, debug layer enabled). Default FXC and DXC builds both matched all 256 pixels. Dropping the mask select failed against the reference and matched the separate whole-dword image. Physical GPU and title results remain unverified. [WARP verification](https://github.com/avt0m4t48/Xbox2Windows/actions/runs/45499068258) Source-built inputs only. AI-assisted using Codex.
upstream-sync closed this pull request 2026-11-24 23:03:20 +00:00
ChazY11 commented 2026-11-24 23:03:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:24:42Z.


Ran it, broke four things, and one survivor turned out to be a better diagnostic rather than a gap

Windows 11 build 26300.9974, device-free:

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_vopc_sdwa_check.py
class reference keeps 144 of 256 pixels: ok
ignoring the class mask select changes the image: ok
PASS      exit 0

Mutations to tools/startup/gfx2hlsl.py, each reverted:

mutation result
SRC1's selector ignored (read the whole dword instead of the selected field) caught
the float source accepts a non-DWORD selection caught
float_src0 ignored, so the float source goes through the integer mask path caught
if selection != 'DWORD' or sext: → if selection != 'DWORD': (sign extension accepted) not caught

I checked the fourth one before calling it a hole

It is not a hole. Driving the stage directly with the two-source form:

guard present:
  sext(v0) src0_sel:DWORD   -> Unsupported: v_cmp_class_f32_sdwa requires a DWORD float source
guard's sext half removed:
  sext(v0) src0_sel:DWORD   -> Unsupported: operand 'sext(v0)'
  sext(v0) src0_sel:BYTE_1  -> Unsupported: v_cmp_class_f32_sdwa requires a DWORD float source

So the sext half of the condition does not decide whether the instruction is refused — self.f() rejects the sext(...) token
anyway — it only decides which message a reader gets. Nothing wrong is emitted either way, so the missing case is a diagnostic
nicety, not missing coverage:

# optional, only for the message: the guard should name the rule, not the operand parser.
with self.assertRaisesRegex(Unsupported, "requires a DWORD float source"):
    translate('v_cmp_class_f32_sdwa vcc_lo, sext(v0), v1 src0_sel:DWORD src1_sel:DWORD')

If you would rather keep the suite at behaviour only, leaving it out is defensible — I am flagging it because I expected it to be a
gap and it was not.

What the class path gets right

  • SRC0 is read as the whole float through self.f(), and SRC1's selected byte/word/dword becomes the mask — the split the ISA
    describes, and the two mutations that break either half both fail.
  • check_compare_sdwa_destination separates v_cmpx (sources only) from v_cmp (scalar destination first) and refuses a
    destination that is not vcc/exec/an SGPR, which is the same rule the non-SDWA path already had.
  • base.removesuffix('_sdwa') keeps one predicate table for both encodings instead of a parallel one, so the ten class bits cannot
    drift between them.

What this does not establish

Nothing device-side from me: the WARP result (Microsoft Basic Render Driver 10.0.26100.33648, 256 pixels, -Gis/default
differences) is your run, and the physical-GPU and title parts stay unverified as the description says. The 68,626-pattern
classifier cross-check I did not rerun here — it lives in the other fixture.

Verdict

Reviewed. Three behaviours pinned, one guard is belt-and-braces, no acceptance hole found.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146195579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1969#issuecomment-7146195579). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:24:42Z. --- ## Ran it, broke four things, and one survivor turned out to be a better diagnostic rather than a gap Windows 11 build 26300.9974, device-free: ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_vopc_sdwa_check.py class reference keeps 144 of 256 pixels: ok ignoring the class mask select changes the image: ok PASS exit 0 ``` Mutations to `tools/startup/gfx2hlsl.py`, each reverted: | mutation | result | |---|---| | SRC1's selector ignored (read the whole dword instead of the selected field) | **caught** | | the float source accepts a non-`DWORD` selection | **caught** | | `float_src0` ignored, so the float source goes through the integer mask path | **caught** | | `if selection != 'DWORD' or sext:` → `if selection != 'DWORD':` (sign extension accepted) | not caught | ## I checked the fourth one before calling it a hole It is **not** a hole. Driving the stage directly with the two-source form: ```text guard present: sext(v0) src0_sel:DWORD -> Unsupported: v_cmp_class_f32_sdwa requires a DWORD float source guard's sext half removed: sext(v0) src0_sel:DWORD -> Unsupported: operand 'sext(v0)' sext(v0) src0_sel:BYTE_1 -> Unsupported: v_cmp_class_f32_sdwa requires a DWORD float source ``` So the `sext` half of the condition does not decide *whether* the instruction is refused — `self.f()` rejects the `sext(...)` token anyway — it only decides **which message** a reader gets. Nothing wrong is emitted either way, so the missing case is a diagnostic nicety, not missing coverage: ```python # optional, only for the message: the guard should name the rule, not the operand parser. with self.assertRaisesRegex(Unsupported, "requires a DWORD float source"): translate('v_cmp_class_f32_sdwa vcc_lo, sext(v0), v1 src0_sel:DWORD src1_sel:DWORD') ``` If you would rather keep the suite at behaviour only, leaving it out is defensible — I am flagging it because I expected it to be a gap and it was not. ## What the class path gets right - SRC0 is read as the whole float through `self.f()`, and SRC1's selected byte/word/dword becomes the mask — the split the ISA describes, and the two mutations that break either half both fail. - `check_compare_sdwa_destination` separates `v_cmpx` (sources only) from `v_cmp` (scalar destination first) and refuses a destination that is not `vcc`/`exec`/an SGPR, which is the same rule the non-SDWA path already had. - `base.removesuffix('_sdwa')` keeps one predicate table for both encodings instead of a parallel one, so the ten class bits cannot drift between them. ## What this does not establish Nothing device-side from me: the WARP result (`Microsoft Basic Render Driver 10.0.26100.33648`, 256 pixels, `-Gis`/default differences) is your run, and the physical-GPU and title parts stay unverified as the description says. The 68,626-pattern classifier cross-check I did not rerun here — it lives in the other fixture. ## Verdict Reviewed. Three behaviours pinned, one guard is belt-and-braces, no acceptance hole found. ## Notes - AI-assisted review.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1962
No description provided.