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 @@ -90,6 +90,8 @@ jobs:
(["tests/startup_gfx2hlsl_sop2_complement_check.py", "decode", "libLLVM-15.so.1"], {}),
(["tests/startup_gfx2hlsl_f32_lg_check.py", "binary", "llvm-mc-15"], {}),
(["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_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 @@ -206,6 +208,7 @@ jobs:
tests/startup_gfx2hlsl_vopc_sdwa_check.py \
tests/startup_gfx2hlsl_sop2_complement_check.py \
tests/startup_gfx2hlsl_f32_lg_check.py \
tests/startup_gfx2hlsl_f32_nan_check.py \
tests/startup_inline_sampler_check.py \
tests/startup_buffer_address_check.py \
tests/startup_smem_address_check.py \
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,9 @@ if(EXISTS "${INTAKE_PYTHON}")
# +-0, denormals, +-1, +-max, +-inf and NaNs against the ISA reference; the old != lowering must fail.
add_test(NAME startup_gfx2hlsl_f32_lg COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_f32_lg_check.py")
# 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")
# 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 @@ -2199,6 +2202,14 @@ if(EXISTS "${INTAKE_PYTHON}")
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_gfx2hlsl_f32_lg_${adapter} PROPERTIES TIMEOUT 300 SKIP_RETURN_CODE 77)
endforeach()
# Every lowered f32 condition but lg/nlg decides 16 x 16 pixels with FXC and DXC, checked pixel by pixel (#1936);
# the text before #1936 must fail on the compiler that rewrote it and match that rewrite's image.
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_gfx2hlsl_f32_nan_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_f32_nan_check.py" draw "${DXC_EXECUTABLE}"
"$<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()
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
21 changes: 21 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -6077,6 +6077,27 @@ and matches its own image. Run `ctest --preset dev --no-tests=error -R '^startup
`tests/startup_gfx2hlsl_f32_lg_check.py binary <llvm-mc>` and `decode <libLLVM>` round-trip the forms and the
fixtures through LLVM 15.

**f32 nlt, nle, ngt, nge, o and u under compilers without `-Gis` (#1936).** The startup cache compiles every
`gfx2hlsl` pair with FXC and no flags, and neither compiler keeps float compares IEEE-strict unless asked. FXC
compiled `!(a < b)` to `ge a, b` (and likewise for `<=`, `>`, `>=`), so nlt, nle, ngt and nge gave 0 on every NaN
pair where the ISA gives 1; DXC folded `a != a` and `a == a`, so u was constant 0 and o constant 1. WARP and an
RX 9070 XT (driver 32.0.31044.16) agreed in every case, and `/Gis` or `-Gis` restored the ISA result, so the
bytecode decides it. The n-forms now read `!(ORDERED && a OP b)` and o and u read ORDERED and `!ORDERED`, with
ORDERED the bit test of both source words that lg uses; neq is unchanged, as both compilers keep `!(a == b)` true
on NaN. `startup_gfx2hlsl_f32_nan` evaluates the HLSL of all 510 f32 forms over the 256 source pairs under IEEE
compares and under models of the two rewrites (a negation pushed into the opposite relation; reflexive float
relations folded, and less-or-greater read as unordered not-equal, #1920); each equals the ISA reference, and the
text before #1936 fails all 204 forms of the six conditions under the model of the compiler that broke it. The
draws `startup_gfx2hlsl_f32_nan_{warp,hardware}` write four results of each of the 13 conditions other than lg
and nlg (e32, and e64 with `(-a, |b|)`, `(-|a|, -b)`, `(|a|, b)`) and keep pixels through `v_cmpx_*_e64` for the
six, compiled with 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 #1936 fails each draw on the compiler that
rewrote it (156 NaN pixels against the flushed image) and matches that rewrite's image; on the other compiler it
is recorded, and it matched. Also recorded, not checked: with `/Gis` and `-Gis` the old and the new text of the six
both matched every pixel. Run `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_f32_nan' -V`;
`tests/startup_gfx2hlsl_f32_nan_check.py binary <llvm-mc>` and `decode <libLLVM>` round-trip the fixtures through
LLVM 15.

**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
14 changes: 7 additions & 7 deletions tests/startup_gfx2hlsl_f32_lg_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ def first_mismatch(expr, cond, mods, model=reference):
return None


# The lowering of every other condition before #1920, for v_cmp_*_f32_e32 vcc_lo, v1, v2.
# The lowering of every other condition before #1920, for v_cmp_*_f32_e32 vcc_lo, v1, v2. nlt, nle, ngt, nge, o and u
# changed with #1936 and are checked in tests/startup_gfx2hlsl_f32_nan_check.py.
UNCHANGED = {'f': 'false', 'lt': 'F(v1) < F(v2)', 'eq': 'F(v1) == F(v2)', 'le': 'F(v1) <= F(v2)',
'gt': 'F(v1) > F(v2)', 'ge': 'F(v1) >= F(v2)', 'o': '(F(v1) == F(v1) && F(v2) == F(v2))',
'u': '(F(v1) != F(v1) || F(v2) != F(v2))', 'nge': '!(F(v1) >= F(v2))', 'ngt': '!(F(v1) > F(v2))',
'nle': '!(F(v1) <= F(v2))', 'neq': '!(F(v1) == F(v2))', 'nlt': '!(F(v1) < F(v2))'}
'gt': 'F(v1) > F(v2)', 'ge': 'F(v1) >= F(v2)', 'neq': '!(F(v1) == F(v2))'}
NAN_FORMS = ('nlt', 'nle', 'ngt', 'nge', 'o', 'u')


def controls():
Expand All @@ -375,7 +375,7 @@ def controls():
(old_reference(cond, a, b) != reference(cond, a, b)) == (is_nan(a) or is_nan(b))
for cond in ('lg', 'nlg') for a, b in PAIRS))
check('every f32 condition of the table is checked (%d opcodes)' % len(F32_OPS), len(F32_OPS) == 30 and sorted(
{COMPARES[op][1] for op in F32_OPS}) == sorted(set(UNCHANGED) | {'lg', 'nlg'}))
{COMPARES[op][1] for op in F32_OPS}) == sorted(set(UNCHANGED) | {'lg', 'nlg'} | set(NAN_FORMS)))

# 2. The new lowering's text; every other condition keeps its text.
asm, stage = translate(compare_code(0x05, 'e32'))
Expand All @@ -391,12 +391,12 @@ def controls():
changed = []
for op in F32_OPS:
cmpx, cond, _ = COMPARES[op]
if cmpx or cond in ('lg', 'nlg'):
if cmpx or cond in ('lg', 'nlg') + NAN_FORMS:
continue
asm, stage = translate(compare_code(op, 'e32'))
if stage.lines != ['vcc = ((%s) ? 1u : 0u);' % UNCHANGED[cond]]:
changed.append((asm, stage.lines))
check('the 13 other conditions keep their lowering', not changed, str(changed))
check('the %d other conditions keep their lowering' % len(UNCHANGED), not changed, str(changed))

# 3. Every form of every condition equals the reference on every pair; the old lg/nlg lowering does not.
forms = evaluations = 0
Expand Down
Loading
Loading