shader: lower the f64 compares (v_cmp/v_cmpx_*_f64 and class) #100
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!100
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-100"
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?
@lcg007xd-c on GitHub · 2026-11-25 22:45 UTC · original
lcg007xd-c:shader-f64-cmp→main· +149 −0 · 2 files · 2 commits · openWhat is broken
The f64 compares decode, but
compare()inemit/lower.rshas nof64arm:v_cmp_*_f64v_cmpx_*_f64v_cmp_class_f64v_cmpx_class_f64So a program that uses the result (VCC to a
v_cndmask, a branch, or EXEC forv_cmpx) fails withv_cmp_lt_f64 is not supported(and likewise). The earlier coverage run only caught thev_cmpxforms, because av_cmpwhose VCC nobody reads is dead code. I confirmed it through the CPU harness of #62 withv_cmp_lt_f64feedingv_cndmask_b32.The change (
emit/lower.rs, incompare)f64predicates: the same predicate table as f32, on the host's doubles.f64_pair(withabs/neg) and joined byMakeDouble, with theDOUBLESflag set.lgisolt | ogt, as the f32 arm does, for the AMD driver reason noted there.f64class: the f32 class test on the binary64's bits, with no double arithmetic. The exponent (11 bits) and the quiet bit (mantissa bit 51) are in the high dword, and the mantissa test spans both dwords.Tests
emit::lower::tests::f64_compares_translate(every host):v_cmp_lt/lg/neq_f64andv_cmp_class_f64feedingv_cndmask_b32, andv_cmpx_gt_f64writing EXEC before a store, all decode and translate. Without thelower.rschange it fails:v_cmp_lt_f64 [7c420701, d5010000, 01a90280]: GFX10 code at 0x28: v_cmp_lt_f64 is not supported.valu_tests::f64_compares_match_ieee(Windows/GPU): 8 predicates on 6 pairs, against Rust's f64. The pairs are ordered both ways, equal, NaN, ±0 and a one-ulp difference.lli. All 16 predicates on all 121 pairs of 11 values (±0, ±inf, NaN, denormal, ±large), against Rust's f64 comparisons, all match. So doesv_cmp_class_f64for every class bit on ±1, ±0, ±denormal, ±inf, a quiet and a signalling NaN.Run here (Linux, Rust 1.98.1):
cargo test -p victory-shader --lib --locked: 188 passed, 0 failed, 2 ignored.CARGO_FEATURE_PURE=1 cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.Not run here: the GPU case, since I have no Windows machine. This needs double-precision shader ops on the host, like #99 and the existing whole-wave f64 sum. The class test itself needs none.
🤖 Generated with Claude Code
VOPC 0x20..=0x3F and 0xA8/0xB8 decoded, but compare() had no f64 arm, so a v_cmp_lt_f64 whose result is used failed ("v_cmp_lt_f64 is not supported"). The f32 predicates now apply to the host's doubles (the operand pairs, with abs/neg, joined by MakeDouble; DOUBLES flag), lg as olt|ogt as for f32. v_cmp_class_f64 classifies the binary64's bits as the f32 class does, the exponent and quiet bit being in the high dword. Co-Authored-By: Claude Opus 5.5 <[email protected]>@lmouz823-lang on GitHub · 2026-11-27 14:58 UTC · original
I can take the native Windows/NVIDIA validation for this PR at exact head
8dbb58ec15295d9da7fba6f4f471b969d2bce43a:f64_compares_translateandf64_compares_match_ieee. I have Windows 11, Rust/MSVC, an RTX 4060 Laptop (8 GiB, driver 610.88), and the SDK DXIL validator. I will verify that the hardware case executes, keep the WARP result separate, and report exact commands, failures or passes, and coverage limits here.AI-assisted with Codex.
@lmouz823-lang on GitHub · 2026-11-27 15:02 UTC · original
Native Windows/NVIDIA validation completed on the unchanged PR head
8dbb58ec15295d9da7fba6f4f471b969d2bce43a.Environment: Windows 11 build 26200, RTX 4060 Laptop 8 GiB, NVIDIA driver 610.88, Rust 1.98.1 MSVC.
VICTORY_STRICT_TESTS=1;VICTORY_WARPwas unset.VICTORY_DXILexplicitly selected the Windows SDKdxil.dll1.8.2502.11. The helper's validator-load branch is optional, so this is not a separate validator-loading regression test.Both exact tests passed, with no ignored tests or device skips:
The GPU log identified both backends:
The existing GPU case checked all 8 predicates × 6 input pairs on each backend, including ordered/reversed/equal values, a NaN operand, signed zero and a one-ulp difference.
v_cmp_class_f64andv_cmpx_gt_f64were covered by the translation test only; this does not add hardware validation for their class/EXEC behavior or for the other 8 predicates. AMD, the full workspace suite and game execution were not tested.No source changes were needed; the worktree remains clean. AI-assisted validation with Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.