Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ jobs:
(["tests/startup_gfx2hlsl_f32_lg_check.py", "decode", "libLLVM-15.so.1"], {}),
(["tests/startup_gfx2hlsl_f32_nan_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_f32_nan_check.py", "decode", "libLLVM-15.so.1"], {}),
(["tests/startup_gfx2hlsl_f32_sdwa_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_f32_sdwa_check.py", "decode", "libLLVM-15.so.1"], {}),
(["tests/startup_inline_sampler_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_smem_address_check.py", "binary", "llvm-mc-15"], {}),
(["tests/compute_entry_layout_check.py", "binary", "llvm-mc-15"], {}),
Expand Down Expand Up @@ -233,6 +235,7 @@ jobs:
tests/startup_gfx2hlsl_sopk_accum_check.py \
tests/startup_gfx2hlsl_f32_lg_check.py \
tests/startup_gfx2hlsl_f32_nan_check.py \
tests/startup_gfx2hlsl_f32_sdwa_check.py \
tests/startup_gfx2hlsl_root_check.py \
tests/startup_gfx2hlsl_sopk_signext_check.py \
tests/startup_inline_sampler_check.py \
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,10 @@ if(EXISTS "${INTAKE_PYTHON}")
# f32 nlt/nle/ngt/nge, o and u hold under FXC's and DXC's rewrites of float compares without -Gis (#1936).
add_test(NAME startup_gfx2hlsl_f32_nan COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_f32_nan_check.py")
# f32 SDWA compares (#1906): DWORD selections emit the e64 text and equal the ISA reference over the same 256 pairs
# under the IEEE, FXC and DXC models; every byte/word selection is refused; the text before #1930/#1949 must fail.
add_test(NAME startup_gfx2hlsl_f32_sdwa COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_f32_sdwa_check.py")
# A negated source on the vector select flips that source's sign bit (#1709).
add_test(NAME startup_gfx2hlsl_cndmask_neg COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_cndmask_neg_check.py")
Expand Down Expand Up @@ -2683,6 +2687,14 @@ if(EXISTS "${INTAKE_PYTHON}")
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_gfx2hlsl_f32_nan_${adapter} PROPERTIES TIMEOUT 300 SKIP_RETURN_CODE 77)
endforeach()
# Every f32 condition in its DWORD SDWA form decides 16 x 16 pixels with default-flag FXC and DXC, checked pixel
# by pixel (#1906); the text before #1930/#1949 must fail on the compiler that broke it.
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_gfx2hlsl_f32_sdwa_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_f32_sdwa_check.py" draw "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_gfx2hlsl_f32_sdwa_${adapter} PROPERTIES TIMEOUT 300 SKIP_RETURN_CODE 77)
endforeach()
add_test(NAME startup_gfx2hlsl_mad_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_mad_check.py")
foreach(adapter IN ITEMS warp hardware)
Expand Down
36 changes: 33 additions & 3 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -6502,8 +6502,9 @@ Run `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_opsel$' -V`.
**VOPC SDWA compares (#1906).** `compare()` refused every `v_cmp*_sdwa` and `v_cmpx*_sdwa`. It now lowers the
SDWA forms of its 32-bit table. An i32 or u32 source reads its `src0_sel`/`src1_sel` field through `sdwa_source`,
sign-extended under `sext()`, and the compare reads that 32-bit value as its type. Binary32 class compares read
a DWORD float from SRC0 and select the integer class mask from SRC1. Ordinary f32 predicates stay refused
in their SDWA form until their NaN behavior is verified (#1920). The
a DWORD float from SRC0 and select the integer class mask from SRC1. Ordinary f32 predicates were refused in
their SDWA form until their NaN behavior was verified (#1920); DWORD selections are now lowered (f32 SDWA entry
below). The
destination is `vcc_lo`, the SGPR the decoder prints, or EXEC for `v_cmpx` with the same EXEC masking as before.
A sub-dword class value, a missing or repeated select and unsupported SDWA modifiers are refused.
`startup_gfx2hlsl_vopc_sdwa` evaluates the emitted class predicate for 42 forms across all ten binary32 classes,
Expand Down Expand Up @@ -6541,7 +6542,8 @@ fixtures matched); FXC on both backends and DXC on WARP gave the ordered result.
`startup_gfx2hlsl_f32_lg` decodes every f32 condition of the table (v_cmp and v_cmpx, e32 and e64 under every
neg/abs combination, 510 forms), translates it and evaluates the HLSL over all 256 pairs of +-0, +-min denormal,
+-1.0, +-max finite, +-inf, +-quiet, signalling and payload NaN against a reference built from the ISA
definitions on the bit patterns; the old `!=` text fails all 68 lg/nlg forms, and the f32 SDWA forms stay refused.
definitions on the bit patterns; the old `!=` text fails all 68 lg/nlg forms. The f32 SDWA lg/nlg forms with DWORD
selections must emit the e64 text (see the f32 SDWA entry below).
The draws `startup_gfx2hlsl_f32_lg_{warp,hardware}` build one of those words from the pixel's x and one from its
y, so 16 x 16 pixels cover every pair, and write `v_cmp_lg_f32_e32`, `v_cmp_nlg_f32_e64`, `v_cmp_lg_f32_e64` and
`v_cmp_nlg_f32_e32` results or keep a pixel through `v_cmpx_lg/nlg_f32_e32/e64`, compiled with FXC `ps_5_1` and
Expand Down Expand Up @@ -6574,6 +6576,34 @@ both matched every pixel. Run `ctest --preset dev --no-tests=error -R '^startup_
`tests/startup_gfx2hlsl_f32_nan_check.py binary <llvm-mc>` and `decode <libLLVM>` round-trip the fixtures through
LLVM 15.

**f32 SDWA compares (#1906).** `compare()` refused every `v_cmp_*_f32_sdwa` and `v_cmpx_*_f32_sdwa` until the f32
predicates were exact on NaN (#1930, #1949). DWORD selections are now lowered: they read the register as binary32
with neg/abs as in the e64 form, so a `src0_sel:DWORD src1_sel:DWORD` compare emits the e64 text of the same
modifiers, NaN bit test included. Byte and word selections are refused
(`<name>: f32 SDWA byte/word selection depends on the binary32 denormal mode`), because the selected field is always
+0 or a denormal and its result depends on the denormal mode, which gfx2hlsl does not read. `tools/pixel_aot.py`
refuses the same forms. `sext()` is integer-only (LLVM's `AMDGPUModifierSyntax`) and refused; LLVM 15 does not
decode the bit on a float source. LLVM's `SIPeepholeSDWA` models the sub-dword case as zero-extension read as
binary32 bits; the RDNA 2 ISA guide gives only the SDWAB fields (§13.3.8) and says VOPC SDWA has no OMOD, CLMP,
DST_U or DST_SEL (§6.8). `startup_gfx2hlsl_f32_sdwa` builds and decodes every f32 SDWA form: 15 conditions; v_cmp
into `vcc_lo` and into an SGPR, v_cmpx into EXEC; 7 x 7 selects; 4 x 4 neg/abs. Each of the 720 DWORD/DWORD forms
must emit the e64 text, and its HLSL is evaluated over the 256 source pairs of the lg check under the IEEE, FXC and
DXC models of the nan check (184,320 evaluations) against the ISA reference. Each of the 34,560 forms with a byte or
word select on either source must be refused with that message. The text before #1930/#1949 on the same operands
fails all 128 guarded forms under the model of the compiler that broke it. The draws
`startup_gfx2hlsl_f32_sdwa_{warp,hardware}` write four DWORD/DWORD results of each condition (`(a, b)`,
`(-a, |b|)`, `(-|a|, -b)`, `(|a|, b)`, into `vcc_lo` and SGPRs) and keep pixels through
`v_cmpx_<cond>_f32_sdwa -v3, |v4| src0_sel:DWORD src1_sel:DWORD`, 30 fixtures compiled with default-flag FXC
`ps_5_1` and DXC `ps_6_0`. Every pixel matched on WARP and the RX 9070 XT with both compilers (denormal sources
flushed where they matter). The text before #1930/#1949 fails each draw on the compiler that broke it (lg/nlg on
both) and matches that compiler's model. The exception is o and u under DXC: their old text keeps each source's
modifiers, and DXC folded `x == x` for `(a, b)` and `(-a, |b|)` in `cmp_o`/`cmp_u` but not for `(-|a|, -b)` or
`(|a|, b)`. In `cmpx_o`/`cmpx_u`, DXC folded the `|b|` side but not the `-a` side. Those matches are recorded, as
are the old text on the other compiler and `/Gis`/`-Gis` runs (every fixture matched). Run
`ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_f32_sdwa' -V`;
`tests/startup_gfx2hlsl_f32_sdwa_check.py binary <llvm-mc>` and `decode <libLLVM>` round-trip all 35,280 forms
(lowered and refused) and the fixtures through LLVM 15. Class compares are unchanged.

**Four half channels in a typed buffer load.** `BUF_FMT_16_16_16_16_FLOAT` stores x and y in the first
dword and z and w in the second, and the typed-load format table had only the two-channel half-float
form, so a load of this format was refused with `buffer format BUF_FMT_16_16_16_16_FLOAT` - 5 of the 29
Expand Down
22 changes: 14 additions & 8 deletions tests/startup_gfx2hlsl_f32_lg_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
neg/abs combination on both sources) is decoded from words built here, translated, and the emitted HLSL is evaluated
on the CPU with IEEE binary32 comparisons over every pair of 16 source words: +-0, +-min denormal, +-1.0, +-max
finite, +-inf, +-quiet NaN, +-signalling NaN and +-NaN with a payload. The same forms with the old `!=` lowering
restored must disagree with the reference. The f32 SDWA compares stay refused.
restored must disagree with the reference. The f32 SDWA lg/nlg forms with DWORD selections must lower as the e64
form; tests/startup_gfx2hlsl_f32_sdwa_check.py checks every f32 SDWA form.

The draws: a source-built pixel program builds one of those 16 words from the pixel's x and one from its y with
integer operations, so 16 x 16 pixels cover every pair: finite unequal, equal (+0 and -0 among them), infinite and
Expand Down Expand Up @@ -452,8 +453,9 @@ def controls():
wrong.append((asm, hex(a), hex(b), lane))
check('inactive lane: lg/nlg results masked by EXEC in the e32 and e64 forms', not wrong, str(wrong[:3]))

# 5. The f32 SDWA compares stay refused (#1906): lg and nlg, v_cmp and v_cmpx, with and without modifiers.
refused = []
# 5. The f32 SDWA lg/nlg compares (#1906) with DWORD selections: the same text as the e64 form with the same
# modifiers. Every f32 SDWA form is checked in tests/startup_gfx2hlsl_f32_sdwa_check.py.
differ = []
for op in F32_OPS:
cmpx, cond, _ = COMPARES[op]
if cond not in ('lg', 'nlg'):
Expand All @@ -462,12 +464,16 @@ def controls():
name, asm = decode_one(vopc_sdwa(op, source('v', 1, neg=neg, absolute=absolute), source('v', 2),
None if cmpx else SGPR_DST))
try:
Probe().one(name, asm)
refused.append((asm, None))
stage = Probe()
stage.one(name, asm)
except G.Unsupported as error:
refused.append((asm, str(error)))
check('f32 SDWA lg/nlg compares stay refused (%d forms)' % len(refused), len(refused) == 16 and all(
error == '%s: f32 SDWA compares are not lowered' % asm.split()[0] for asm, error in refused), str(refused[:3]))
differ.append((asm, str(error)))
continue
_asm, e64 = translate(compare_code(op, 'e64', ((neg, absolute), (False, False))))
if stage.lines != e64.lines:
differ.append((asm, stage.lines, e64.lines))
check('f32 SDWA lg/nlg compares with DWORD selections lower as the e64 form (16 forms)', not differ,
str(differ[:3]))


# ---- the pixel fixtures -----------------------------------------------------------------------------------------
Expand Down
Loading
Loading