recomp: f64 abs / neg modifiers on the sign bit #71

Closed
gefydev wants to merge 2 commits from upstream-pr/72 into main
gefydev commented 2026-11-23 00:28:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-23T00:28:04Z.


On top of #71, which is what runs this test on NVIDIA. Only the last commit is new.

The f64 source modifiers are emitted as -x (NEG) and abs(x) (ABS). DXIL (LLVM 3.7) has no fneg, so DXC compiles -x as fsub double -0.0, x, and IEEE 754 doesn't define the sign of a NaN result there. AMD happens to flip it. On a GTX 1650, v_frexp_mant_f64 with NEG on 0x7FF8000000000001 returns 0x7FF8000000000001 instead of 0xFFF8000000000001:

assertion `left == right` failed: lane 8 v_frexp_mant_f64 neg
  left: 9221120237041090561
 right: 18444492273895866369

On RDNA the modifiers only flip or clear the sign bit, NaN included. f64v now applies them that way, to the high dword: asdouble(lo, hi ^ 0x80000000u) and asdouble(lo, hi & 0x7FFFFFFFu). For anything but NaN the value is the same as before.

f32 operands (fsrc) still use -x / abs(). I haven't seen a failing case there, so I left them alone.

Validation

GTX 1650, Windows 11, NVIDIA driver 32.0.16.2114 (and before that the same GPU on Linux with vkd3d-proton). On Windows, cargo test --workspace has 0 failures and gpu_frexp_f64_exp_and_mant runs and passes. The failure output above is from vkd3d-proton; on Windows I only ran it with the fix.

  • gpu_frexp_f64_exp_and_mant now uses gpu_ready_wave32. It fails without this commit (above) and passes with it.
  • f64_class_compare_vopc_and_vop3, frexp_f64_instructions and rndne_f64_instructions check the generated HLSL, so they now expect the new form.
  • cargo test -p xcl --lib: 0 failed on the GTX 1650 (19 SKIPPED) and without a GPU.
<!-- greyfinch-sync:ivall/xcl:issue:6549793200 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/72). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-23T00:28:04Z. --- On top of #71, which is what runs this test on NVIDIA. Only the last commit is new. The f64 source modifiers are emitted as `-x` (NEG) and `abs(x)` (ABS). DXIL (LLVM 3.7) has no `fneg`, so DXC compiles `-x` as `fsub double -0.0, x`, and IEEE 754 doesn't define the sign of a NaN result there. AMD happens to flip it. On a GTX 1650, `v_frexp_mant_f64` with NEG on `0x7FF8000000000001` returns `0x7FF8000000000001` instead of `0xFFF8000000000001`: ``` assertion `left == right` failed: lane 8 v_frexp_mant_f64 neg left: 9221120237041090561 right: 18444492273895866369 ``` On RDNA the modifiers only flip or clear the sign bit, NaN included. `f64v` now applies them that way, to the high dword: `asdouble(lo, hi ^ 0x80000000u)` and `asdouble(lo, hi & 0x7FFFFFFFu)`. For anything but NaN the value is the same as before. f32 operands (`fsrc`) still use `-x` / `abs()`. I haven't seen a failing case there, so I left them alone. ## Validation GTX 1650, Windows 11, NVIDIA driver 32.0.16.2114 (and before that the same GPU on Linux with vkd3d-proton). On Windows, `cargo test --workspace` has 0 failures and `gpu_frexp_f64_exp_and_mant` runs and passes. The failure output above is from vkd3d-proton; on Windows I only ran it with the fix. - `gpu_frexp_f64_exp_and_mant` now uses `gpu_ready_wave32`. It fails without this commit (above) and passes with it. - `f64_class_compare_vopc_and_vop3`, `frexp_f64_instructions` and `rndne_f64_instructions` check the generated HLSL, so they now expect the new form. - `cargo test -p xcl --lib`: 0 failed on the GTX 1650 (19 `SKIPPED`) and without a GPU.
upstream-sync closed this pull request 2026-11-24 06:57:01 +00:00
FZNull commented 2026-11-24 07:00:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by FZNull on 2026-11-23T00:51:52Z.


Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100.

  • base dd713e3 / PR head a7a2074 (this PR includes #71)
  • cargo test --workspace --no-fail-fast: 372 -> 373 passed, 0 failed, 34 ignored
  • SKIPPED ...: no wave64 drops from 41 to 19, so 22 GPU tests that never ran on this adapter now run and pass
  • cargo test -p xcl --lib: 343 -> 344 passed

No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used.

AI-assisted.

<!-- greyfinch-sync:ivall/xcl:comment:7088693467 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/72#issuecomment-7088693467). Originally posted by [FZNull](https://github.com/FZNull) on 2026-11-23T00:51:52Z. --- Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100. - base `dd713e3` / PR head `a7a2074` (this PR includes #71) - `cargo test --workspace --no-fail-fast`: **372 -> 373 passed, 0 failed, 34 ignored** - `SKIPPED ...: no wave64` drops from **41 to 19**, so 22 GPU tests that never ran on this adapter now run and pass - `cargo test -p xcl --lib`: 343 -> 344 passed No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used. _AI-assisted._
ivall commented 2026-11-24 07:00:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:20:59Z.


Landed as c2887bb (cherry-picked, authorship kept), without #71 – #67 already runs these kernels on 32-lane GPUs, so the test now gates on gpu_ready instead of gpu_ready_wave32. Passes on an RX 9070 natively and with XCL_SPLIT_WAVE64=1 (the 32-lane split form forced on RDNA). Closing here since the commit is on main. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7097813370 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/72#issuecomment-7097813370). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T10:20:59Z. --- Landed as c2887bb (cherry-picked, authorship kept), without #71 – #67 already runs these kernels on 32-lane GPUs, so the test now gates on `gpu_ready` instead of `gpu_ready_wave32`. Passes on an RX 9070 natively and with `XCL_SPLIT_WAVE64=1` (the 32-lane split form forced on RDNA). Closing here since the commit is on `main`. Thanks!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!71
No description provided.