From 1b9e82848139bd328145fee646bfb88e6efae51e Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Tue, 24 Nov 2026 16:49:20 +0000 Subject: [PATCH 1/4] shader: lower the 46 non-cmpx SDWA comparisons Lower the VOPC SDWA f16 predicates and class test, the f32 class test, and the 16- and 32-bit signed and unsigned integer predicates. Sources accept BYTE_0..3, WORD_0..1 and DWORD selections with sext(); VOPC SDWA has no dst_sel/dst_unused, so the result stays in vcc/vcc_lo or one SGPR. Add the draw-sdwa-cmp fixture with selection, width, signedness, sext and destination-overwrite controls, the coverage assertions, the scanner patterns and the experiments.md reproduction. Measured on 0aa6522c: gfx1013 1255/1968 -> 1301/1968, gfx1030 1246/1863 -> 1292/1863. --- CMakeLists.txt | 5 + docs/experiments.md | 2 + tests/form_coverage_check.py | 35 ++++ tests/pixel_aot_check.py | 299 ++++++++++++++++++++++++++++++ tests/rdna2_tools_check.py | 26 ++- tools/pixel_aot.py | 105 ++++++++++- tools/scan_unsupported_shaders.py | 19 ++ 7 files changed, 488 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 695875318a..e3d8849140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6422,6 +6422,11 @@ if(EXISTS "${INTAKE_PYTHON}") "$" ${adapter}) set_tests_properties(pixel_aot_comparisons_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77 ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_comparisons_${adapter}.txt") + add_test(NAME pixel_aot_sdwa_cmp_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-sdwa-cmp "${DXC_EXECUTABLE}" + "$" ${adapter}) + set_tests_properties(pixel_aot_sdwa_cmp_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77 + ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/pixel_aot_sdwa_cmp_${adapter}.txt") add_test(NAME pixel_aot_get_lod_${adapter} COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/pixel_get_lod_check.py" draw "${DXC_EXECUTABLE}" "$" ${adapter}) diff --git a/docs/experiments.md b/docs/experiments.md index 3ded6656c5..b485bf35d8 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -5965,6 +5965,8 @@ Scalar ALU support also covers the 64-bit SOP1/SOP2 family (`s_cmov_b64`, `s_not The SDWA forms of the 16 `v_cmp_*_f32` predicates are lowered when both `src0_sel` and `src1_sel` are `DWORD`. With whole-dword selections they compare the operands exactly as the e32/e64 forms do; the translator emits identical HLSL for both, and a control asserts it. A byte or word selection would compare a zero-extended field as binary32 and is refused. The predicate draws are repeated with the SDWA compares for all four groups and the same five input pairs, including NaN on either side. A reference that inverts each group's unordered result must report a mismatch. +The 46 non-`v_cmpx` VOPC SDWA comparisons left by lot 1a are lowered: the 16 binary16 predicates and `v_cmp_class_f16_sdwa`, `v_cmp_class_f32_sdwa`, the 8 signed and 8 unsigned 32-bit predicates and the 6 signed and 6 unsigned 16-bit predicates. VOPC SDWA encodes only `src0_sel` and `src1_sel`; `llvm-mc` rejects `dst_sel`/`dst_unused` on these instructions, so the destination stays `vcc`/`vcc_lo` or one SGPR and the translator refuses an SGPR pair and the destination fields. Sources accept `BYTE_0..3`, `WORD_0..1` and `DWORD`, with `sext()` where LLVM prints it. The selection is zero-extended, or sign-extended under `sext()`, before the existing table applies: binary16 uses the low 16 bits through `widen16`/`num16`, the 16-bit integer forms take the low 16 bits, the 32-bit integer forms compare the selected word as signed or unsigned, and the class forms feed the selected bits to `class16` or `class32`. The comparison result is tracked in the same VCC/SGPR lane-mask state as the e32 and e64 forms, so `v_cndmask_b32` consumes it unchanged. The source-built fixture `tests/pixel_aot_check.py draw-sdwa-cmp` puts all 46 forms in one program, folds each predicate into two exported `R32G32B32A32_UINT` words, and repeats the rows with selections on every field. Its wrong references must each report `pixel_mismatch`: selections ignored (whole dwords), every field reversed (`BYTE_0`/`BYTE_3`, `BYTE_1`/`BYTE_2`, `WORD_0`/`WORD_1`), signedness inverted on the rows containing `0x8000`/`0xffff`, and zero extension in place of `sext()`. A second program writes two comparisons to `s52` and `vcc_lo` before consuming both; a reference that uses the second mask for both channels must mismatch. `tests/form_coverage_check.py` isolates this fixture's accepted words and asserts the 46 forms count in both `gfx1013.tsv` and `rdna2.tsv`, while the non-SDWA `v_cmp_*` neighbours and the `v_cmpx_*_sdwa` forms stay out. On base `0aa6522c` the measurement moved from 1255/1968 to 1301/1968 on gfx1013 and from 1246/1863 to 1292/1863 on gfx1030, exactly 46 forms in each reference. The new tests passed on WARP and on `pixel_aot_sdwa_cmp_hardware` on an AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Windows 11 build 10.0.26300.10075, in 1.10 s; the debug layer was unavailable. The separate `pixel_aot_comparisons_hardware` entry still fails on this adapter in its pre-existing strict binary32 subnormal comparison ([issue #958](https://github.com/R0Y00/Xbox2Windows/issues/958)); that failure is outside this lot and does not affect the SDWA draw. This measures translated fixtures, not console behavior or full title execution. Reproduce with `ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_cmp_' -V`; the full measurement is `ctest --preset dev --no-tests=error -R '^(pixel_aot_|compute_store_aot_)' -E '_hardware$' -j 1 --output-junit out/build/dev/out/wave1-sdwa-after.xml` followed by `python -B tools/form_coverage.py out/build/dev/out/wave1-sdwa-after.xml --records out/build/dev/form_coverage --json out/wave1-sdwa-after.json`. + Binary32 floating-point vector comparisons (`v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32` in e32, e64, and whole-dword SDWA forms) evaluate the 16 IEEE-754 relations against scalar and vector operands, including subnormals, signed zeroes, infinities, and quiet/signaling NaNs. The e32 (VOPC) encoding requires destination `vcc` or `vcc_lo`; SGPR destinations (`s52`, `s[52:53]`) are accepted on suffix-less and explicit `_e64` (VOP3) encodings. Source modifiers (`neg`, `abs`) are accepted on e64 operands (`-s44`, `|v18|`, `-|s44|`), while `clamp` and `op_sel` remain rejected on comparisons. Rejection controls verify that untracked source registers, SGPR destinations on explicit e32, and sub-dword SDWA selections (`src0_sel:WORD_0`, `src1_sel:BYTE_2`) raise `ValueError`. The synthetic fixture `f32_compares()` verifies all 16 predicates across e32, e64, and whole-dword SDWA, validating them against an exact reference oracle (`f32_compares_reference()`). Mutating predicates or modifiers produces a mismatch. The original [#958](https://github.com/R0Y00/Xbox2Windows/issues/958) report at `0f0c3eb` recorded a strict comparison mismatch on an RX 9070 XT. Predicate bit 18 compares binary32 subnormal `0x00000001` with `-0.0` and should be clear. The hardware readback set it while WARP and the separate denormal-preservation control passed. The strict expectation and predicate mutation controls are unchanged. Reproduce with `ctest --preset dev --no-tests=error -R '^pixel_aot_comparisons_(warp|hardware)$' -V`. See the reduced desktop DXIL measurements below and the additional adapter results in #958. diff --git a/tests/form_coverage_check.py b/tests/form_coverage_check.py index 3b5da7ed29..bb61d1723d 100644 --- a/tests/form_coverage_check.py +++ b/tests/form_coverage_check.py @@ -1307,6 +1307,40 @@ def check_pk_fmac_coverage(): assert ("VOP2", "v_pk_fmac_f16") not in fc.gfx_forms(stripped, reference), name +def check_sdwa_cmp_coverage(): + """The 46 non-cmpx VOPC SDWA comparisons count in both references, and their non-SDWA + neighbours do not: the isolated fixture accepts only the selected forms and its own mask/ALU + support instructions. This is the coverage half of the negative control; the draw carries the + selection and signedness mismatches.""" + import pixel_aot_check as pixel + wanted = {("SDWA", entry["form"]) for entry in pixel.SDWA_CMP_FORMS} + assert len(wanted) == 46 + saved = set(pixel.ACCEPTED) + pixel.ACCEPTED.clear() + try: + pixel.translate_int(pixel.uncompressed_export(pixel.sdwa_cmp_body())) + accepted = set(pixel.ACCEPTED) + finally: + pixel.ACCEPTED.clear() + pixel.ACCEPTED.update(saved) + for name in ("gfx1013.tsv", "rdna2.tsv"): + reference = fc.load_reference(name) + assert wanted <= reference, (name, sorted(wanted - reference)) + covered = fc.gfx_forms(accepted, reference) + assert wanted <= covered, (name, sorted(wanted - covered)) + # Non-SDWA neighbours and the exec-writing cmpx forms are not in this fixture's record. + assert not {("VOPC", f"v_cmp_{op}_f16") for op in pixel.PREDICATES} & covered, name + assert not {("VOPC", f"v_cmp_{op}_f32") for op in pixel.PREDICATES} & covered, name + assert not {("VOPC", f"v_cmp_{op}_{kind}") for op in pixel.INT_PREDICATES + for kind in ("i32", "u32")} & covered, name + assert not {("VOPC", f"v_cmp_{op}_{kind}") for op in ("eq", "ne", "lt", "le", "gt", "ge") + for kind in ("i16", "u16")} & covered, name + assert not {("SDWA", f"v_cmpx_{op}_f16_sdwa") for op in pixel.PREDICATES} & covered, name + # Control: removing one accepted SDWA word removes exactly that form from the count. + stripped = accepted - {"v_cmp_lt_f16_sdwa"} + assert ("SDWA", "v_cmp_lt_f16_sdwa") not in fc.gfx_forms(stripped, reference), name + + if __name__ == "__main__": check_denominators() check_example() @@ -1329,6 +1363,7 @@ def check_pk_fmac_coverage(): check_f16_to_int16_forms() check_swap_coverage() check_pk_fmac_coverage() + check_sdwa_cmp_coverage() check_sopk_wait_forms() check_s_version_form() check_parsing() diff --git a/tests/pixel_aot_check.py b/tests/pixel_aot_check.py index 424103565a..eb8e49aab1 100644 --- a/tests/pixel_aot_check.py +++ b/tests/pixel_aot_check.py @@ -4318,6 +4318,298 @@ def check_sdwa_predicate_draws(directory, compiler, renderer, backend): raise +# The 46 non-cmpx VOPC SDWA comparisons. VOPC SDWA has source selections and a lane-mask destination, +# but llvm-mc accepts no dst_sel/dst_unused on these instructions. The selections rotate through every +# byte, word and dword field; sext() appears on one form of each integer width. +SDWA_CMP_F16_SELECTIONS = ( + ("WORD_0", "WORD_1"), ("WORD_1", "WORD_0"), ("BYTE_0", "BYTE_1"), ("BYTE_1", "BYTE_0"), + ("BYTE_2", "BYTE_3"), ("BYTE_3", "BYTE_2"), ("DWORD", "WORD_0"), ("WORD_0", "DWORD"), + ("BYTE_0", "WORD_1"), ("WORD_1", "BYTE_1"), ("BYTE_2", "DWORD"), ("DWORD", "BYTE_3"), + ("BYTE_1", "WORD_0"), ("WORD_0", "BYTE_2"), ("BYTE_3", "WORD_1"), ("DWORD", "DWORD"), +) +SDWA_CMP_I32_SELECTIONS = ("DWORD", "BYTE_0", "BYTE_1", "BYTE_2", "BYTE_3", "WORD_0", "WORD_1", "DWORD") +SDWA_CMP_I16_OPS = ("eq", "ne", "lt", "le", "gt", "ge") +SDWA_CMP_I16_SELECTIONS = ( + ("BYTE_0", "WORD_0"), ("BYTE_1", "WORD_1"), ("BYTE_2", "WORD_0"), + ("BYTE_3", "WORD_1"), ("WORD_0", "BYTE_2"), ("WORD_1", "BYTE_3"), +) +SDWA_CMP_FORMS = ( + tuple((f"v_cmp_{op}_f16_sdwa", "f16", op, sel0, sel1, False, False) + for op, (sel0, sel1) in zip(PREDICATES, SDWA_CMP_F16_SELECTIONS)) + + (("v_cmp_class_f16_sdwa", "class_f16", "class", "WORD_1", "BYTE_1", False, False), + ("v_cmp_class_f32_sdwa", "class_f32", "class", "BYTE_2", "BYTE_1", False, False)) + + tuple((f"v_cmp_{op}_i32_sdwa", "i32", op, sel, "DWORD", op == "lt", False) + for op, sel in zip(INT_PREDICATES, SDWA_CMP_I32_SELECTIONS)) + + tuple((f"v_cmp_{op}_u32_sdwa", "u32", op, sel, "DWORD", op == "gt", False) + for op, sel in zip(INT_PREDICATES, SDWA_CMP_I32_SELECTIONS)) + + tuple((f"v_cmp_{op}_i16_sdwa", "i16", op, sel0, sel1, op == "le", False) + for op, (sel0, sel1) in zip(SDWA_CMP_I16_OPS, SDWA_CMP_I16_SELECTIONS)) + + tuple((f"v_cmp_{op}_u16_sdwa", "u16", op, sel1, sel0, False, op == "ge") + for op, (sel0, sel1) in zip(SDWA_CMP_I16_OPS, SDWA_CMP_I16_SELECTIONS)) +) +SDWA_CMP_FORMS = tuple({"form": entry[0], "kind": entry[1], "op": entry[2], + "sel0": entry[3], "sel1": entry[4], "sext0": entry[5], "sext1": entry[6]} + for entry in SDWA_CMP_FORMS) +assert len(SDWA_CMP_FORMS) == 46 + +# Runtime words: s44 is A and s45/v18 is B. Their byte, word and dword fields disagree, and the signed +# rows put 0x8000/0xffff in the selected halves so a signedness or selection error changes a bit. +SDWA_CMP_WORDS = ( + (0x00000000, 0x00000000), + (0x00000001, 0x00000001), + (0x04030201, 0x01020304), + (0x00010000, 0x00008000), + (0x7f800000, 0x00000200), + (0x7e007c00, 0x3c000000), + (0x8000ffff, 0x00010001), + (0x7fff8000, 0x80007fff), + (0x12345678, 0x87654321), + (0x0000c000, 0x00004000), +) + + +def sdwa_cmp_instruction(entry, dst): + src0 = "sext(s44)" if entry["sext0"] else "s44" + src1 = "sext(v18)" if entry["sext1"] else "v18" + return (f"{entry['form']} {dst}, {src0}, {src1} " + f"src0_sel:{entry['sel0']} src1_sel:{entry['sel1']}") + + +def sdwa_cmp_body(): + """Every one of the 46 forms, each folded into bit i of the two exported uint words.""" + body = ["v_mov_b32_e32 v18, s45", "v_mov_b32_e32 v12, 0", "v_mov_b32_e32 v13, 0", + "v_mov_b32_e32 v14, 0", "v_mov_b32_e32 v15, 0"] + for index, entry in enumerate(SDWA_CMP_FORMS): + dst = "s52" if index % 7 == 3 else "vcc_lo" + body.append(sdwa_cmp_instruction(entry, dst)) + body.append(f"v_cndmask_b32_{'e64' if dst.startswith('s') else 'e32'} v20, 0, 1, {dst}") + body.append(f"v_lshlrev_b32_e32 v20, {index % 32}, v20") + body.append(f"v_or_b32_e32 v{12 + index // 32}, v{12 + index // 32}, v20") + return body + + +def sdwa_field(word, sel, sext): + offset, width = pixel_aot.SDWA_SEL[sel] + value = (word >> offset) & ((1 << width) - 1) + if sext and value & (1 << (width - 1)): + value -= 1 << width + return value & 0xffffffff + + +def f16_bits_value(bits): + return struct.unpack(" b, "lg": a < b or a > b, + "ge": a >= b} + if op in relation: + return relation[op] + base = {"nge": "ge", "nlg": "lg", "ngt": "gt", "nle": "le", "neq": "eq", "nlt": "lt"}[op] + return not relation[base] + + +def class16_reference(bits): + h = bits & 0xffff + magnitude = h & 0x7fff + negative = h >= 0x8000 + if magnitude > 0x7c00: + return 0x2 if h & 0x0200 else 0x1 + if magnitude == 0x7c00: + return 0x4 if negative else 0x200 + if magnitude >= 0x0400: + return 0x8 if negative else 0x100 + if magnitude: + return 0x10 if negative else 0x80 + return 0x20 if negative else 0x40 + + +def class32_reference(bits): + magnitude = bits & 0x7fffffff + negative = bits >= 0x80000000 + if magnitude > 0x7f800000: + return 0x2 if bits & 0x00400000 else 0x1 + if magnitude == 0x7f800000: + return 0x4 if negative else 0x200 + if magnitude >= 0x00800000: + return 0x8 if negative else 0x100 + if magnitude: + return 0x10 if negative else 0x80 + return 0x20 if negative else 0x40 + + +def int_cmp_reference(op, left, right): + return {"f": False, "lt": left < right, "eq": left == right, "le": left <= right, + "gt": left > right, "ne": left != right, "ge": left >= right, "t": True}[op] + + +def sdwa_cmp_expected(entry, word0, word1, *, select=None, signed=None, sext=True): + sel0 = entry["sel0"] if select is None else select(entry["sel0"]) + sel1 = entry["sel1"] if select is None else select(entry["sel1"]) + a = sdwa_field(word0, sel0, entry["sext0"] if sext else False) + b = sdwa_field(word1, sel1, entry["sext1"] if sext else False) + kind = entry["kind"] + if kind == "f16": + return f16_cmp_reference(entry["op"], a, b) + if kind == "class_f16": + return (class16_reference(a) & (b & 0xffffffff)) != 0 + if kind == "class_f32": + return (class32_reference(a) & b) != 0 + if kind in ("i32", "u32"): + use_signed = kind == "i32" if signed is None else signed + left = a - 0x100000000 if use_signed and a & 0x80000000 else a + right = b - 0x100000000 if use_signed and b & 0x80000000 else b + return int_cmp_reference(entry["op"], left, right) + use_signed = kind == "i16" if signed is None else signed + left, right = a & 0xffff, b & 0xffff + if use_signed: + left -= 0x10000 if left & 0x8000 else 0 + right -= 0x10000 if right & 0x8000 else 0 + return int_cmp_reference(entry["op"], left, right) + + +def sdwa_cmp_expected_words(word0, word1, *, select=None, signed=None, sext=True): + words = [0, 0, 0, 0] + for index, entry in enumerate(SDWA_CMP_FORMS): + if sdwa_cmp_expected(entry, word0, word1, select=select, signed=signed, sext=sext): + words[index // 32] |= 1 << (index % 32) + return tuple(words) + + +def sdwa_cmp_destination_body(): + """Two comparisons to different lane masks, both consumed after the second is written.""" + return ["v_mov_b32_e32 v18, s45", + "v_cmp_eq_u32_sdwa s52, s44, v18 src0_sel:BYTE_0 src1_sel:DWORD", + "v_cmp_eq_u32_sdwa vcc_lo, s44, v18 src0_sel:BYTE_0 src1_sel:WORD_1", + "v_cndmask_b32_e64 v12, 0, 1, s52", + "v_cndmask_b32_e32 v13, 0, 1, vcc_lo", + "v_mov_b32_e32 v14, 0", "v_mov_b32_e32 v15, 0"] + + +def sdwa_cmp_destination_expected(word0, word1): + return (int((word0 & 0xff) == (word1 & 0xffffffff)), + int((word0 & 0xff) == ((word1 >> 16) & 0xffff)), 0, 0) + + +def check_sdwa_cmp_controls(directory): + """Static checks: all 46 forms lower, the destination rules hold, the neighbours stay refused.""" + assert len(SDWA_CMP_FORMS) == 46 and len({entry["form"] for entry in SDWA_CMP_FORMS}) == 46 + source = translate_int(uncompressed_export(sdwa_cmp_body())) + assert source.count("bool cmp") == 46 + missing = [entry["form"] for entry in SDWA_CMP_FORMS if entry["form"] not in ACCEPTED] + assert not missing, missing + # Subtracting the correct high word from a WORD_1 source is present in the emitted HLSL. + assert ">> 16u" in source + # VOPC SDWA has no destination field beyond the lane mask: dst_sel/dst_unused never assemble. + for extra in ("dst_sel:WORD_0 dst_unused:UNUSED_PAD ", "dst_sel:DWORD dst_unused:UNUSED_SEXT ", + "dst_sel:BYTE_0 dst_unused:UNUSED_PRESERVE "): + must_reject(translate_int, uncompressed_export([ + "v_cmp_eq_i32_sdwa vcc_lo, s44, v18 " + extra + "src0_sel:BYTE_0 src1_sel:DWORD"])) + # Selections are exactly the byte, word and dword fields the encoding has. + for bad in ("WORD_2", "BYTE_4", "QWORD_0"): + must_reject(translate_int, uncompressed_export([ + f"v_cmp_eq_i32_sdwa vcc_lo, s44, v18 src0_sel:{bad} src1_sel:DWORD"])) + # A lane mask is one VCC or one SGPR, not an SGPR pair; unbalanced sext() and missing fields refuse. + must_reject(translate_int, uncompressed_export([ + "v_cmp_eq_i32_sdwa s[0:1], s44, v18 src0_sel:BYTE_0 src1_sel:DWORD"])) + must_reject(translate_int, uncompressed_export([ + "v_cmp_eq_i32_sdwa vcc_lo, sext(s44, v18 src0_sel:BYTE_0 src1_sel:DWORD"])) + must_reject(translate_int, uncompressed_export([ + "v_cmp_eq_i32_sdwa vcc_lo, s44, v18 src0_sel:BYTE_0"])) + # The f32 floating comparisons keep their whole-dword-only rule; class f32 is separate. + must_reject(translate, uncompressed_export([ + "v_cmp_lt_f32_sdwa vcc_lo, s44, v18 src0_sel:WORD_1 src1_sel:DWORD"])) + # The exec-writing neighbours remain outside this lot, and a non-SDWA compare is not accepted by + # this fixture's own assembly vocabulary. + must_reject(translate, uncompressed_export([ + "v_cmpx_lt_f16_sdwa vcc_lo, s44, v18 src0_sel:WORD_0 src1_sel:WORD_1"])) + # The destination draw keeps its two mask results independent. + dest = translate_int(uncompressed_export(sdwa_cmp_destination_body())) + assert dest.count("bool cmp") == 2 + return 0 + + +def check_sdwa_cmp_draw(directory, compiler, renderer, backend): + """Draw the 46 selected comparisons and the destination-tracking control.""" + check_sdwa_cmp_controls(directory) + source = directory / "sdwa_cmp.hlsl" + shader = directory / "sdwa_cmp.cso" + source.write_text(translate_int(uncompressed_export(sdwa_cmp_body())), encoding="ascii") + compile_shader(compiler, source, shader) + cases = [] + for index, (word0, word1) in enumerate(SDWA_CMP_WORDS): + constants = bytearray(256) + struct.pack_into("<2I", constants, 12, word0, word1) + expected = sdwa_cmp_expected_words(word0, word1) + path = directory / f"sdwa-cmp-{index}.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in expected), integer_rt=True) + cases.append((path, "pass")) + # Selection ignored: compare whole dwords for every form. + word0, word1 = SDWA_CMP_WORDS[2] + constants = bytearray(256) + struct.pack_into("<2I", constants, 12, word0, word1) + ignored = sdwa_cmp_expected_words(word0, word1, select=lambda _sel: "DWORD") + assert ignored != sdwa_cmp_expected_words(word0, word1) + path = directory / "sdwa-cmp-selection-ignored.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in ignored), integer_rt=True) + cases.append((path, "mismatch")) + # Width reversed: BYTE_0 <-> BYTE_3, BYTE_1 <-> BYTE_2, WORD_0 <-> WORD_1. + reverse = {"BYTE_0": "BYTE_3", "BYTE_1": "BYTE_2", "BYTE_2": "BYTE_1", "BYTE_3": "BYTE_0", + "WORD_0": "WORD_1", "WORD_1": "WORD_0", "DWORD": "DWORD"} + reversed_words = sdwa_cmp_expected_words(word0, word1, select=reverse.__getitem__) + assert reversed_words != sdwa_cmp_expected_words(word0, word1) + path = directory / "sdwa-cmp-width-reversed.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in reversed_words), integer_rt=True) + cases.append((path, "mismatch")) + # Signed instead of unsigned, on the rows where 0xffff and 0x8000 select negative halves. + word0, word1 = SDWA_CMP_WORDS[6] + constants = bytearray(256) + struct.pack_into("<2I", constants, 12, word0, word1) + signed = sdwa_cmp_expected_words(word0, word1, signed=True) + assert signed != sdwa_cmp_expected_words(word0, word1) + path = directory / "sdwa-cmp-signed.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in signed), integer_rt=True) + cases.append((path, "mismatch")) + # Zero extension instead of sext(), on the same row. The sexted forms select 0xff, so the two + # signed comparisons change result; the reference is the lowering without the sext bits. + zero = sdwa_cmp_expected_words(word0, word1, sext=False) + assert zero != sdwa_cmp_expected_words(word0, word1) + path = directory / "sdwa-cmp-zero-extended.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in zero), integer_rt=True) + cases.append((path, "mismatch")) + run_pixel_batch(renderer, backend, shader, cases) + # Destination overwritten: the two masks must keep their own comparison result. + source.write_text(translate_int(uncompressed_export(sdwa_cmp_destination_body())), encoding="ascii") + compile_shader(compiler, source, shader) + dest_cases = [] + dest_rows = ((0x00000001, 0x00010000), (0x00000001, 0x00000001), (0x00000002, 0x00020002)) + for index, (word0, word1) in enumerate(dest_rows): + constants = bytearray(256) + struct.pack_into("<2I", constants, 12, word0, word1) + expected = sdwa_cmp_destination_expected(word0, word1) + path = directory / f"sdwa-cmp-dest-{index}.case" + write_case(path, bytes(constants), tuple(as_float(word) for word in expected), integer_rt=True) + dest_cases.append((path, "pass")) + wrong = sdwa_cmp_destination_expected(*dest_rows[0]) + wrong = (wrong[1], wrong[1], 0, 0) # both channels take the second comparison + path = directory / "sdwa-cmp-dest-overwritten.case" + constants = bytearray(256) + struct.pack_into("<2I", constants, 12, *dest_rows[0]) + write_case(path, bytes(constants), tuple(as_float(word) for word in wrong), integer_rt=True) + dest_cases.append((path, "mismatch")) + run_pixel_batch(renderer, backend, shader, dest_cases) + return 0 + + def half_rtz(x): bits, = struct.unpack("> 16)" if kind == "i16" else f"({word} & 0xffffu)" + for word in raw] + for j, reg in enumerate(regs): + scalar[reg] = ("condition", f"cmp{i}", j, len(regs)) + lines.append(f" bool cmp{i} = {INT_COMPARE[op].format(*values)};") elif m := match(rf"v_cndmask_b32(?:_e32|_e64)? (v\d+), ([^,]+), ([^,]+), {LANE_MASK}"): dst, unset, chosen, source = m.groups() regs = lane_mask(source) diff --git a/tools/scan_unsupported_shaders.py b/tools/scan_unsupported_shaders.py index 7de7ff4b33..2138efbf91 100644 --- a/tools/scan_unsupported_shaders.py +++ b/tools/scan_unsupported_shaders.py @@ -104,6 +104,8 @@ def lower_rejection_causes(results: list[dict]) -> dict: F16_PLAIN = r"(?:-?(?:\d+\.\d+|\d+)|0x[0-9a-f]{1,4}|[vs]\d+)" F16_MOD = rf"-?(?:\|{F16_PLAIN}\||abs\({F16_PLAIN}\)|{F16_PLAIN})" SDWA_SEL_PATTERN = r"(?:BYTE_[0-3]|WORD_[01]|DWORD)" +PIXEL_SDWA_DST = r"(?:vcc(?:_lo)?|s\d+)" +SDWA_CMP_SOURCE = rf"(?:sext\({INTEGER_SOURCE}\)|{INTEGER_SOURCE})" CVT_F32_E64_BASE = r"(?:[vs]\d+|0x[0-9a-f]{1,8})" CVT_F32_E64_ABS = rf"(?:\|{CVT_F32_E64_BASE}\||abs\({CVT_F32_E64_BASE}\))" CVT_F32_E64_SOURCE = rf"(?:neg\((?:{CVT_F32_E64_ABS}|{CVT_F32_E64_BASE})\)|-(?:{CVT_F32_E64_ABS}|[vs]\d+)|{CVT_F32_E64_ABS}|{CVT_F32_E64_BASE})" @@ -223,11 +225,28 @@ def lower_rejection_causes(results: list[dict]) -> dict: SUPPORTED_INSTRUCTIONS_REGEX.append( rf"v_cmp_(?:{cmp_ops})_f16_e64\s+{PIXEL_LANE_MASK},\s+{F16_MOD},\s+{F16_MOD}" ) + # VOPC SDWA has only the two source selections; the destination is VCC or one SGPR. + SUPPORTED_INSTRUCTIONS_REGEX.append( + rf"v_cmp_(?:{cmp_ops})_f16_sdwa\s+{PIXEL_SDWA_DST},\s+{SDWA_CMP_SOURCE},\s+{SDWA_CMP_SOURCE}" + rf"\s+src0_sel:{SDWA_SEL_PATTERN}\s+src1_sel:{SDWA_SEL_PATTERN}" + ) + SUPPORTED_INSTRUCTIONS_REGEX.append( + rf"v_cmp_class_(?:f16|f32)_sdwa\s+{PIXEL_SDWA_DST},\s+{SDWA_CMP_SOURCE},\s+{SDWA_CMP_SOURCE}" + rf"\s+src0_sel:{SDWA_SEL_PATTERN}\s+src1_sel:{SDWA_SEL_PATTERN}" + ) if PIXEL_INT_COMPARE: icmp_ops = "|".join(map(re.escape, PIXEL_INT_COMPARE)) SUPPORTED_INSTRUCTIONS_REGEX.append( rf"v_cmp_(?:{icmp_ops})_(?:i32|u32|i16|u16){PIXEL_VOPC_DST},\s+{INTEGER_SOURCE},\s+{INTEGER_SOURCE}" ) + SUPPORTED_INSTRUCTIONS_REGEX.append( + rf"v_cmp_(?:{icmp_ops})_(?:i32|u32)_sdwa\s+{PIXEL_SDWA_DST},\s+{SDWA_CMP_SOURCE},\s+{SDWA_CMP_SOURCE}" + rf"\s+src0_sel:{SDWA_SEL_PATTERN}\s+src1_sel:{SDWA_SEL_PATTERN}" + ) + SUPPORTED_INSTRUCTIONS_REGEX.append( + rf"v_cmp_(?:eq|ne|lt|le|gt|ge)_(?:i16|u16)_sdwa\s+{PIXEL_SDWA_DST},\s+{SDWA_CMP_SOURCE},\s+{SDWA_CMP_SOURCE}" + rf"\s+src0_sel:{SDWA_SEL_PATTERN}\s+src1_sel:{SDWA_SEL_PATTERN}" + ) # 64-bit comparisons are checked by supports_int64_compare() below: the pair and inline ranges are numeric. INT64_COMPARE_PATTERN = re.compile( rf"v_cmp_(?:{icmp_ops})_(?:i64|u64)(_e32|_e64)?\s+(vcc(?:_lo)?|s\d+|s\[\d+:\d+\]),\s+(\S+),\s+(\S+)" From bca2702c3a1fe2c085ae3c2880dfe338d5afefaa Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Tue, 24 Nov 2026 19:22:00 +0000 Subject: [PATCH 2/4] shader: round-trip the SDWA comparison fixture Use a defined VGPR for the cndmask true value so the program is valid gfx1013 assembly, and add the 46-form program and the destination-overwrite control to check_binary. The gfx1013 assembly job now assembles, disassembles and re-translates every new form instead of only scanning hand-written bytes. --- docs/experiments.md | 3 ++- tests/pixel_aot_check.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/experiments.md b/docs/experiments.md index b485bf35d8..f9e5260034 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -5965,7 +5965,7 @@ Scalar ALU support also covers the 64-bit SOP1/SOP2 family (`s_cmov_b64`, `s_not The SDWA forms of the 16 `v_cmp_*_f32` predicates are lowered when both `src0_sel` and `src1_sel` are `DWORD`. With whole-dword selections they compare the operands exactly as the e32/e64 forms do; the translator emits identical HLSL for both, and a control asserts it. A byte or word selection would compare a zero-extended field as binary32 and is refused. The predicate draws are repeated with the SDWA compares for all four groups and the same five input pairs, including NaN on either side. A reference that inverts each group's unordered result must report a mismatch. -The 46 non-`v_cmpx` VOPC SDWA comparisons left by lot 1a are lowered: the 16 binary16 predicates and `v_cmp_class_f16_sdwa`, `v_cmp_class_f32_sdwa`, the 8 signed and 8 unsigned 32-bit predicates and the 6 signed and 6 unsigned 16-bit predicates. VOPC SDWA encodes only `src0_sel` and `src1_sel`; `llvm-mc` rejects `dst_sel`/`dst_unused` on these instructions, so the destination stays `vcc`/`vcc_lo` or one SGPR and the translator refuses an SGPR pair and the destination fields. Sources accept `BYTE_0..3`, `WORD_0..1` and `DWORD`, with `sext()` where LLVM prints it. The selection is zero-extended, or sign-extended under `sext()`, before the existing table applies: binary16 uses the low 16 bits through `widen16`/`num16`, the 16-bit integer forms take the low 16 bits, the 32-bit integer forms compare the selected word as signed or unsigned, and the class forms feed the selected bits to `class16` or `class32`. The comparison result is tracked in the same VCC/SGPR lane-mask state as the e32 and e64 forms, so `v_cndmask_b32` consumes it unchanged. The source-built fixture `tests/pixel_aot_check.py draw-sdwa-cmp` puts all 46 forms in one program, folds each predicate into two exported `R32G32B32A32_UINT` words, and repeats the rows with selections on every field. Its wrong references must each report `pixel_mismatch`: selections ignored (whole dwords), every field reversed (`BYTE_0`/`BYTE_3`, `BYTE_1`/`BYTE_2`, `WORD_0`/`WORD_1`), signedness inverted on the rows containing `0x8000`/`0xffff`, and zero extension in place of `sext()`. A second program writes two comparisons to `s52` and `vcc_lo` before consuming both; a reference that uses the second mask for both channels must mismatch. `tests/form_coverage_check.py` isolates this fixture's accepted words and asserts the 46 forms count in both `gfx1013.tsv` and `rdna2.tsv`, while the non-SDWA `v_cmp_*` neighbours and the `v_cmpx_*_sdwa` forms stay out. On base `0aa6522c` the measurement moved from 1255/1968 to 1301/1968 on gfx1013 and from 1246/1863 to 1292/1863 on gfx1030, exactly 46 forms in each reference. The new tests passed on WARP and on `pixel_aot_sdwa_cmp_hardware` on an AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Windows 11 build 10.0.26300.10075, in 1.10 s; the debug layer was unavailable. The separate `pixel_aot_comparisons_hardware` entry still fails on this adapter in its pre-existing strict binary32 subnormal comparison ([issue #958](https://github.com/R0Y00/Xbox2Windows/issues/958)); that failure is outside this lot and does not affect the SDWA draw. This measures translated fixtures, not console behavior or full title execution. Reproduce with `ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_cmp_' -V`; the full measurement is `ctest --preset dev --no-tests=error -R '^(pixel_aot_|compute_store_aot_)' -E '_hardware$' -j 1 --output-junit out/build/dev/out/wave1-sdwa-after.xml` followed by `python -B tools/form_coverage.py out/build/dev/out/wave1-sdwa-after.xml --records out/build/dev/form_coverage --json out/wave1-sdwa-after.json`. +The 46 non-`v_cmpx` VOPC SDWA comparisons left by lot 1a are lowered: the 16 binary16 predicates and `v_cmp_class_f16_sdwa`, `v_cmp_class_f32_sdwa`, the 8 signed and 8 unsigned 32-bit predicates and the 6 signed and 6 unsigned 16-bit predicates. VOPC SDWA encodes only `src0_sel` and `src1_sel`; `llvm-mc` rejects `dst_sel`/`dst_unused` on these instructions, so the destination stays `vcc`/`vcc_lo` or one SGPR and the translator refuses an SGPR pair and the destination fields. Sources accept `BYTE_0..3`, `WORD_0..1` and `DWORD`, with `sext()` where LLVM prints it. The selection is zero-extended, or sign-extended under `sext()`, before the existing table applies: binary16 uses the low 16 bits through `widen16`/`num16`, the 16-bit integer forms take the low 16 bits, the 32-bit integer forms compare the selected word as signed or unsigned, and the class forms feed the selected bits to `class16` or `class32`. The comparison result is tracked in the same VCC/SGPR lane-mask state as the e32 and e64 forms, so `v_cndmask_b32` consumes it unchanged. The source-built fixture `tests/pixel_aot_check.py draw-sdwa-cmp` puts all 46 forms in one program, folds each predicate into two exported `R32G32B32A32_UINT` words, and repeats the rows with selections on every field. Its wrong references must each report `pixel_mismatch`: selections ignored (whole dwords), every field reversed (`BYTE_0`/`BYTE_3`, `BYTE_1`/`BYTE_2`, `WORD_0`/`WORD_1`), signedness inverted on the rows containing `0x8000`/`0xffff`, and zero extension in place of `sext()`. A second program writes two comparisons to `s52` and `vcc_lo` before consuming both; a reference that uses the second mask for both channels must mismatch. `tests/form_coverage_check.py` isolates this fixture's accepted words and asserts the 46 forms count in both `gfx1013.tsv` and `rdna2.tsv`, while the non-SDWA `v_cmp_*` neighbours and the `v_cmpx_*_sdwa` forms stay out. The same program is part of `check_binary`, so the LLVM 15 `Assemble and translate gfx1013 fixtures` job assembles, disassembles and re-translates it. On base `0aa6522c` the measurement moved from 1255/1968 to 1301/1968 on gfx1013 and from 1246/1863 to 1292/1863 on gfx1030, exactly 46 forms in each reference. The new tests passed on WARP and on `pixel_aot_sdwa_cmp_hardware` on an AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Windows 11 build 10.0.26300.10075, in 1.10 s; the debug layer was unavailable. The separate `pixel_aot_comparisons_hardware` entry still fails on this adapter in its pre-existing strict binary32 subnormal comparison ([issue #958](https://github.com/R0Y00/Xbox2Windows/issues/958)); that failure is outside this lot and does not affect the SDWA draw. This measures translated fixtures, not console behavior or full title execution. Reproduce with `ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_cmp_' -V`; the full measurement is `ctest --preset dev --no-tests=error -R '^(pixel_aot_|compute_store_aot_)' -E '_hardware$' -j 1 --output-junit out/build/dev/out/wave1-sdwa-after.xml` followed by `python -B tools/form_coverage.py out/build/dev/out/wave1-sdwa-after.xml --records out/build/dev/form_coverage --json out/wave1-sdwa-after.json`. Binary32 floating-point vector comparisons (`v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32` in e32, e64, and whole-dword SDWA forms) evaluate the 16 IEEE-754 relations against scalar and vector operands, including subnormals, signed zeroes, infinities, and quiet/signaling NaNs. The e32 (VOPC) encoding requires destination `vcc` or `vcc_lo`; SGPR destinations (`s52`, `s[52:53]`) are accepted on suffix-less and explicit `_e64` (VOP3) encodings. Source modifiers (`neg`, `abs`) are accepted on e64 operands (`-s44`, `|v18|`, `-|s44|`), while `clamp` and `op_sel` remain rejected on comparisons. Rejection controls verify that untracked source registers, SGPR destinations on explicit e32, and sub-dword SDWA selections (`src0_sel:WORD_0`, `src1_sel:BYTE_2`) raise `ValueError`. The synthetic fixture `f32_compares()` verifies all 16 predicates across e32, e64, and whole-dword SDWA, validating them against an exact reference oracle (`f32_compares_reference()`). Mutating predicates or modifiers produces a mismatch. @@ -10896,3 +10896,4 @@ Command-list slot 34 no longer sets a title root signature flagged `CBV_SRV_UAV_ cmake --build --preset dev --target startup_stream_consumer startup_heap_indexed_root_check ctest --preset dev --no-tests=error -R "^startup_(heap_indexed_root.*|root_heap_(warp|hardware))$" -V ``` + diff --git a/tests/pixel_aot_check.py b/tests/pixel_aot_check.py index eb8e49aab1..f8e4580a6b 100644 --- a/tests/pixel_aot_check.py +++ b/tests/pixel_aot_check.py @@ -4377,12 +4377,12 @@ def sdwa_cmp_instruction(entry, dst): def sdwa_cmp_body(): """Every one of the 46 forms, each folded into bit i of the two exported uint words.""" - body = ["v_mov_b32_e32 v18, s45", "v_mov_b32_e32 v12, 0", "v_mov_b32_e32 v13, 0", - "v_mov_b32_e32 v14, 0", "v_mov_b32_e32 v15, 0"] + body = ["v_mov_b32_e32 v18, s45", "v_mov_b32_e32 v21, 1", "v_mov_b32_e32 v12, 0", + "v_mov_b32_e32 v13, 0", "v_mov_b32_e32 v14, 0", "v_mov_b32_e32 v15, 0"] for index, entry in enumerate(SDWA_CMP_FORMS): dst = "s52" if index % 7 == 3 else "vcc_lo" body.append(sdwa_cmp_instruction(entry, dst)) - body.append(f"v_cndmask_b32_{'e64' if dst.startswith('s') else 'e32'} v20, 0, 1, {dst}") + body.append(f"v_cndmask_b32_{'e64' if dst.startswith('s') else 'e32'} v20, 0, v21, {dst}") body.append(f"v_lshlrev_b32_e32 v20, {index % 32}, v20") body.append(f"v_or_b32_e32 v{12 + index // 32}, v{12 + index // 32}, v20") return body @@ -4487,11 +4487,11 @@ def sdwa_cmp_expected_words(word0, word1, *, select=None, signed=None, sext=True def sdwa_cmp_destination_body(): """Two comparisons to different lane masks, both consumed after the second is written.""" - return ["v_mov_b32_e32 v18, s45", + return ["v_mov_b32_e32 v18, s45", "v_mov_b32_e32 v21, 1", "v_cmp_eq_u32_sdwa s52, s44, v18 src0_sel:BYTE_0 src1_sel:DWORD", "v_cmp_eq_u32_sdwa vcc_lo, s44, v18 src0_sel:BYTE_0 src1_sel:WORD_1", - "v_cndmask_b32_e64 v12, 0, 1, s52", - "v_cndmask_b32_e32 v13, 0, 1, vcc_lo", + "v_cndmask_b32_e64 v12, 0, v21, s52", + "v_cndmask_b32_e32 v13, 0, v21, vcc_lo", "v_mov_b32_e32 v14, 0", "v_mov_b32_e32 v15, 0"] @@ -17594,6 +17594,8 @@ def check_binary(directory, assembler, objcopy, library): fixtures.extend((int_minmax_pair(encoding), translate) for encoding in ("e32", "e64")) fixtures.extend((int_minmax_triple(kind), translate) for kind in ("i32", "u32")) fixtures.extend((predicate_group(first, sdwa=True), translate) for first in range(0, 16, 4)) + fixtures.append((uncompressed_export(sdwa_cmp_body()), translate_int)) + fixtures.append((uncompressed_export(sdwa_cmp_destination_body()), translate_int)) fixtures.extend((cvt_int_fixture(encoding), translate) for encoding in ("e32", "e64")) fixtures.append((cvt_int_literals(), translate)) fixtures.append((with_constants(CUBE_BODY), translate)) From 04291bc1af781e21702a3f5ba6b23645c97c5893 Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Tue, 24 Nov 2026 20:13:45 +0000 Subject: [PATCH 3/4] tests: pin the SDWA comparison models without a GPU Assert the signed 32-bit compare, the 16-bit sign extension and mask, and both class selections in the generated HLSL. These controls catch the signedness and selection mutations on Linux, before the Windows draws. Also remove the blank line at EOF reported by git diff --check. --- docs/experiments.md | 1 - tests/pixel_aot_check.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/experiments.md b/docs/experiments.md index f9e5260034..115b43d2b2 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -10896,4 +10896,3 @@ Command-list slot 34 no longer sets a title root signature flagged `CBV_SRV_UAV_ cmake --build --preset dev --target startup_stream_consumer startup_heap_indexed_root_check ctest --preset dev --no-tests=error -R "^startup_(heap_indexed_root.*|root_heap_(warp|hardware))$" -V ``` - diff --git a/tests/pixel_aot_check.py b/tests/pixel_aot_check.py index f8e4580a6b..671fd8d3d0 100644 --- a/tests/pixel_aot_check.py +++ b/tests/pixel_aot_check.py @@ -4509,6 +4509,23 @@ def check_sdwa_cmp_controls(directory): assert not missing, missing # Subtracting the correct high word from a WORD_1 source is present in the emitted HLSL. assert ">> 16u" in source + # Device-free guards for the signedness, 16-bit narrowing and class selections. The GPU draws below + # cover the same models, but these fail on Linux when a branch loses asint, the shift or the mask. + model = translate_int(uncompressed_export([ + "v_mov_b32_e32 v18, s45", + "v_cmp_eq_i32_sdwa vcc_lo, s44, v18 src0_sel:BYTE_1 src1_sel:DWORD", + "v_cmp_lt_u32_sdwa vcc_lo, s44, v18 src0_sel:WORD_1 src1_sel:DWORD", + "v_cmp_lt_i16_sdwa vcc_lo, sext(s44), v18 src0_sel:BYTE_1 src1_sel:WORD_0", + "v_cmp_lt_u16_sdwa vcc_lo, s44, v18 src0_sel:WORD_1 src1_sel:BYTE_2", + "v_cmp_class_f16_sdwa vcc_lo, s44, v18 src0_sel:WORD_1 src1_sel:DWORD", + "v_cmp_class_f32_sdwa vcc_lo, s44, v18 src0_sel:BYTE_2 src1_sel:DWORD", + ])) + assert "asint(((params[0].w >> 8u) & 0xffu))" in model + assert "((params[0].w >> 16u) & 0xffffu) < asuint(" in model + assert "<< 16u) >> 16)" in model + assert "0xffffu) & 0xffffu)" in model + assert "class16(((params[0].w >> 16u) & 0xffffu))" in model + assert "class32(asfloat(((params[0].w >> 16u) & 0xffu)))" in model # VOPC SDWA has no destination field beyond the lane mask: dst_sel/dst_unused never assemble. for extra in ("dst_sel:WORD_0 dst_unused:UNUSED_PAD ", "dst_sel:DWORD dst_unused:UNUSED_SEXT ", "dst_sel:BYTE_0 dst_unused:UNUSED_PRESERVE "): From ecce2d6bf1c649d242239ab17ce6b1f0ca7e2cfc Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Tue, 24 Nov 2026 21:22:11 +0000 Subject: [PATCH 4/4] tests: run the SDWA comparison controls on Linux Match the i16 lowering's actual "<<" 16) >> 16)" spelling and register check_sdwa_cmp_controls in the default control set, so the device-free guards run in pixel_aot_check.py and the Linux CI job instead of only inside the GPU draw. --- tests/pixel_aot_check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/pixel_aot_check.py b/tests/pixel_aot_check.py index 671fd8d3d0..8f408f4314 100644 --- a/tests/pixel_aot_check.py +++ b/tests/pixel_aot_check.py @@ -4500,7 +4500,7 @@ def sdwa_cmp_destination_expected(word0, word1): int((word0 & 0xff) == ((word1 >> 16) & 0xffff)), 0, 0) -def check_sdwa_cmp_controls(directory): +def check_sdwa_cmp_controls(directory=None): """Static checks: all 46 forms lower, the destination rules hold, the neighbours stay refused.""" assert len(SDWA_CMP_FORMS) == 46 and len({entry["form"] for entry in SDWA_CMP_FORMS}) == 46 source = translate_int(uncompressed_export(sdwa_cmp_body())) @@ -4522,7 +4522,7 @@ def check_sdwa_cmp_controls(directory): ])) assert "asint(((params[0].w >> 8u) & 0xffu))" in model assert "((params[0].w >> 16u) & 0xffffu) < asuint(" in model - assert "<< 16u) >> 16)" in model + assert "<< 16) >> 16)" in model assert "0xffffu) & 0xffffu)" in model assert "class16(((params[0].w >> 16u) & 0xffffu))" in model assert "class32(asfloat(((params[0].w >> 16u) & 0xffu)))" in model @@ -17054,6 +17054,7 @@ def _check_controls_inline(directory): "check_cvt_int_f64_lowering", "check_cvt_f32_f64_lowering", "check_sdwa_integer_lowering", + "check_sdwa_cmp_controls", "check_pack_int16_lowering", "check_sat_pack_u8_lowering", "check_pack_b32_lowering",