Recompiler: v_min/v_max order -0.0 < +0.0 as RDNA2 does in IEEE mode #1348
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1348
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1348/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@DavidM1911 on GitHub · 2026-11-24 15:05 UTC · original
DavidM1911:fix-1282-minmax→main· +75 −8 · 2 files · 1 commits · closed without mergingv_min_f32/v_max_f32/v_min_f16/v_max_f16and the 3-operand forms emitted plain HLSLmin()/max()→ DXILFMin/FMax, whose-0.0/+0.0result depends on operand order on NVIDIA/WARP. RDNA2 IEEE mode orders-0.0 < +0.0deterministically:v_min(+0,-0) = v_min(-0,+0) = -0,v_maxmirrors to+0.What is in it
fmin_ieee/fmax_ieeeHLSL helpers: NaN-suppressingmin/maxas before, with the both-zero case settled on the sign bits (min: OR keeps-0;max: AND keeps+0). Used for all four f32 forms.f16 -> f32 -> f16loses the sign of zero entirely (measured:v_add_f16(-0,-0)already yields+0on this pipeline), somin16z2/3/max16z2/3settle the zero cases on the raw halves:-0when a-0operand is present and nothing is negative,+0for max when a+0is present and nothing is positive; NaNs and nonzero results defer to the float path.abs/negmodifiers are already bitwise viahb().gpu_min_max_f32_f16_order_negative_zero: both operand orders for all eight instructions, wave32 and wave64.Note: #1301 adds a test-only version of the f32 coverage; this PR includes the f32 fix plus the f16 handling that test does not cover.
Fixes #1282
Tested
cargo test -p xcl --lib recomp: 190 passed, 0 failed, 18 ignored (RTX 3060 Ti, Windows 11, DXC 1.8.2502.11). New test passes on both wave sizes.Regression run
main
930e8b4:head
052af4d:Not tested
macOS / Linux (crate does not build there). f16
-0through other arithmetic ops (e.g.v_add_f16) remains as before — out of scope here.AI use
Devin (Cognition), frontier model. Implemented the fix and tests; ran the suite and smoke above.
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@futurepro62 on GitHub · 2026-11-24 15:14 UTC · original · edited 2026-11-24 15:22 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
052af4d(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_min_max_f32_f16_order_negative_zero.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.main's emitter (main930e8b4with onlytests.rsfrom this PR):gpu_min_max_f32_f16_order_negative_zeropasses there too, 2 of 2 on each GPU. So on these two drivers (RTX 5070 Ti, Radeon RDNA2 iGPU) plainmin/maxalready gave the RDNA2-0/+0answers for the operand orders in the test, and the test does not show the bug here; it would on a driver that gets the order wrong (WARP, per the description). The same goes for #1301's test, which passed onmainon both GPUs here.Not tested
AI use
@lemosss on GitHub · 2026-11-24 15:25 UTC · original
Adding to the report above with what it does not cover: an Ada data point, WARP, and the f64 forms.
Tested (head
052af4d,XCL_TRANSLATED_CACHE=0for every run)gpu_min_max_f32_f16_order_negative_zeropasses on the head, and also withemit.rsput back to930e8b4(the new test kept). Same result as on the RTX 5070 Ti and the RDNA2 iGPU above: on Ada too, plainmin/maxalready give the RDNA2 answers for the cases in the test.XCL_ADAPTER=warp): the test printsSKIPPED … no wave64and runs nothing, with or without the fix. So the WARP failure in the description cannot be shown with this test as it is.v_min_f64/v_max_f64, which this PR leaves on plainmin/max: a throwaway probe on the same build givesmin(+0, −0) = min(−0, +0) = 0x8000000000000000andmax(+0, −0) = max(−0, +0) = 0x0000000000000000on this GPU, i.e. the RDNA2 order already. If the f32 / f16 forms are guarded for drivers that differ, the f64 pair would need the same.Not tested: AMD / wave64, a release build, a retail title.
Run and written with Claude Code (Claude Opus 5.5).
@Darkkandadr on GitHub · 2026-11-24 16:07 UTC · original
An Ampere data point to add to the two reports above. The RTX 3060 has the same architecture as the author's RTX 3060 Ti, but this run used a different driver.
Tested (head
052af4d, on its base930e8b4)cargo test --workspace --no-fail-fast -- --test-threads=4: 751 passed, 1 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.e2e::test_title_draws_with_a_root_signature_under_the_debug_layer, and it is unrelated to this PR. It also fails onmainin my deep checkout, because the overlay path goes pastMAX_PATH. #1015 fixes it (details there).gpu_min_max_f32_f16_order_negative_zeropasses on the head. It also passes with only this PR'stests.rsonmain930e8b4. It ran on the GPU there and was not skipped: DXC loaded, and there was no skip line with--nocapture. So, as on the RTX 5070 Ti, RTX 4060 and RDNA2 iGPU above, plainmin/maxon Ampere with this driver already give the RDNA2-0/+0answers for the cases in the test. The test does not fail without the fix on any GPU reported so far.Not tested
Run and written with Claude Code (Claude Opus 5.5).
@pablogonz12 on GitHub · 2026-11-24 17:02 UTC · original
An RDNA4 / Linux (Wine + vkd3d-proton) data point for head
052af4don its base930e8b4. It adds the wave64 case and an AMD driver wheremin/maxcome from RADV.Tested
x86_64-pc-windows-gnu(llvm-mingw).cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu, test binary run under Wine with--test-threads=4 --skip jumps_to_outer_loop_heads_are_structured: 702 passed, 5 failed, 21 ignored, noSKIPPEDlines. Not the whole workspace: only thexcllib tests.gpu_f64_roots,gpu_f64_math_random,gpu_nonfused_mad_and_mac_prevent_fma_contraction,xma2_source_voice_decodes_and_manages_lifetime,pe::tests::parses_own_test_binary_tls.gpu_min_max_f32_f16_order_negative_zeroandgpu_atomic_fmin_fmax_negative_zeropass on both wave sizes.930e8b4with onlycrates/xcl/src/gpu/recomp/tests.rstaken from this PR gives the same 702 / 5 / 21, and the new test passes. So here, as in the reports above, plainmin/maxalready order -0 below +0 on the GPU, and this test cannot tellmainfrom the PR on this adapter.v_med3_f32(zeros of both signs in all operand orders, plus the clampmed3(-0, 0, 1)) also passes on currentmain(b7aa9f3, which has the plain chain), so I have no failing case forv_med3here either. The PR leavesmed3fas it is.Not tested
jumps_to_outer_loop_heads_are_structured: the process dies in vkd3d-proton'sd3d12core.dllon this setup (#1425), so I skipped it.AI use
@throny on GitHub · 2026-11-24 19:55 UTC · original
Two contributors checked independently and found that #1577 solves the same problem (for #1282) in a different way: #1607, group D3. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@DavidM1911 on GitHub · 2026-11-25 00:12 UTC · original
Fair point — comparing with #1577, it covers the same ground (v_min/v_max/v_min3/v_max3 for f16/f32) plus v_pk_min/max_f16 and v_med3_*, so it's the more complete fix for #1282. This PR is redundant; closing it in favour of #1577. Thanks for the hint.
Pull request closed