Recompiler: v_div_fmas_f32 scales by VCC and v_div_fixup_f32 handles NaN/zero/sign #1135

Open
b3IKK wants to merge 1 commit from upstream-pr/1144 into main
b3IKK commented 2026-11-24 12:32:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T12:32:18Z.


v_div_fmas_f32 emitted mad(s0, s1, s2) and ignored its implicit VCC operand, so lanes with VCC == 1 never got the 2^32 scale (ldexp_f(..., 32)).

div_fixup (v_div_fixup_f32) returned q unchanged when q was NaN (overflow in the division sequence), when n == ±0.0 with finite d, when exp(n) - exp(d) < -150 (underflow), and without setting the result sign to sign(d) ^ sign(n). This replaces div_fixup with an IEEE-754 bit-level implementation covering NaN (numerator before denominator), 0/0, Inf/Inf, x/0, Inf/x, x/Inf, 0/x, exp(n) - exp(d) < -150 underflow, q = NaN overflow, and copysign(q, sign(d) ^ sign(n)).

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: scale v_div_fmas_f32 by 2^32 via ldexp_f for lanes with VCC == 1; update div_fixup for NaN priority (numerator before denominator), zero/inf, exp(n) - exp(d) < -150 underflow, q = NaN overflow, and sign.
  • crates/xcl/src/gpu/recomp/tests.rs: add GPU tests gpu_div_fmas_f32_scales_by_vcc and gpu_div_fixup_f32_special_cases_and_sign (17 cases including numerator-over-denominator NaN priority and the -151 / -150 exponent difference boundary) across wave32 and split wave64 (verified failing before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 753 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib gpu_div_fmas_f32_scales_by_vcc and gpu_div_fixup_f32_special_cases_and_sign: both pass across wave32 and split wave64 (both failed on the GPU before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: eac652c3d11927169ea46739249ebcc188ad800e
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14620 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited emit.rs, wrote the fix and GPU tests, addressed the PortBridge hardware-probe feedback (n NaN priority and exp(n) - exp(d) < -150), ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5472209403 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T12:32:18Z. --- `v_div_fmas_f32` emitted `mad(s0, s1, s2)` and ignored its implicit `VCC` operand, so lanes with `VCC == 1` never got the `2^32` scale (`ldexp_f(..., 32)`). `div_fixup` (`v_div_fixup_f32`) returned `q` unchanged when `q` was `NaN` (overflow in the division sequence), when `n == ±0.0` with finite `d`, when `exp(n) - exp(d) < -150` (underflow), and without setting the result sign to `sign(d) ^ sign(n)`. This replaces `div_fixup` with an IEEE-754 bit-level implementation covering NaN (numerator before denominator), `0/0`, `Inf/Inf`, `x/0`, `Inf/x`, `x/Inf`, `0/x`, `exp(n) - exp(d) < -150` underflow, `q = NaN` overflow, and `copysign(q, sign(d) ^ sign(n))`. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: scale `v_div_fmas_f32` by `2^32` via `ldexp_f` for lanes with `VCC == 1`; update `div_fixup` for NaN priority (numerator before denominator), zero/inf, `exp(n) - exp(d) < -150` underflow, `q = NaN` overflow, and sign. - `crates/xcl/src/gpu/recomp/tests.rs`: add GPU tests `gpu_div_fmas_f32_scales_by_vcc` and `gpu_div_fixup_f32_special_cases_and_sign` (17 cases including numerator-over-denominator NaN priority and the `-151` / `-150` exponent difference boundary) across wave32 and split wave64 (verified failing before the fix). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 753 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib gpu_div_fmas_f32_scales_by_vcc` and `gpu_div_fixup_f32_special_cases_and_sign`: both pass across wave32 and split wave64 (both failed on the GPU before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: eac652c3d11927169ea46739249ebcc188ad800e gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1642 (PresentX 1642) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14620 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `emit.rs`, wrote the fix and GPU tests, addressed the PortBridge hardware-probe feedback (`n` NaN priority and `exp(n) - exp(d) < -150`), ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
DavidM1911 commented 2026-11-24 13:03:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:53:07Z.


Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib div_fmas: 1 passed, 0 failed — gpu_div_fmas_f32_scales_by_vcc covers VCC scaling and the NaN/zero/sign fixup cases on real hardware.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7132051395 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7132051395). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T12:53:07Z. --- Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11. - `cargo test -p xcl --lib div_fmas`: **1 passed, 0 failed** — `gpu_div_fmas_f32_scales_by_vcc` covers VCC scaling and the NaN/zero/sign fixup cases on real hardware. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
TobiasFornell commented 2026-11-24 13:03:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by TobiasFornell on 2026-11-24T12:57:01Z.


AMD / Linux data point – the PR was tested on NVIDIA only, where native wave64 is not available.

Tested: RX 9070 XT (RDNA4, native wave64), Mesa RADV 26.3.1, CachyOS (kernel 7.3), Proton Experimental 11.0-20261112 Wine with vkd3d-proton v3.1 (scripts/linux build), DXC 1.9.2609, x86_64-pc-windows-msvc cross-build, release. Head 2aa8211 merged onto main 47efa2e (clean), together with #1158.

  • gpu_div_fmas_f32_scales_by_vcc and gpu_div_fixup_f32_special_cases_and_sign: pass, including the native wave64 path.
  • Same two tests with the emit.rs change reverted (tests kept): both fail, e.g. wave64 lane 1 (vcc=true) v_div_fmas_f32 – left: 1088421888, right: 1356857344. So the fix is confirmed on AMD hardware too.

Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.

<!-- greyfinch-sync:ivall/xcl:comment:7132139138 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7132139138). Originally posted by [TobiasFornell](https://github.com/TobiasFornell) on 2026-11-24T12:57:01Z. --- AMD / Linux data point – the PR was tested on NVIDIA only, where native wave64 is not available. **Tested:** RX 9070 XT (RDNA4, native wave64), Mesa RADV 26.3.1, CachyOS (kernel 7.3), Proton Experimental `11.0-20261112` Wine with vkd3d-proton v3.1 (`scripts/linux` build), DXC 1.9.2609, `x86_64-pc-windows-msvc` cross-build, release. Head `2aa8211` merged onto `main` `47efa2e` (clean), together with #1158. - `gpu_div_fmas_f32_scales_by_vcc` and `gpu_div_fixup_f32_special_cases_and_sign`: **pass**, including the native wave64 path. - Same two tests with the `emit.rs` change reverted (tests kept): **both fail**, e.g. `wave64 lane 1 (vcc=true) v_div_fmas_f32` – `left: 1088421888, right: 1356857344`. So the fix is confirmed on AMD hardware too. *Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.*
b3IKK commented 2026-11-24 14:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T13:54:36Z.


Thanks @akimfomin! Updated \eac652c\ to check numerator NaN before denominator NaN and apply \exp(n) - exp(d) < -150\ underflow before quotient NaN, added GPU test cases for both (including the -151\ vs -150\ boundary), re-ran the full test suite (753 passed, 0 failed, 41 ignored) and refreshed the 60 s smoke block.

<!-- greyfinch-sync:ivall/xcl:comment:7133518162 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7133518162). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T13:54:36Z. --- Thanks @akimfomin! Updated \eac652c\ to check numerator NaN before denominator NaN and apply \exp(n) - exp(d) < -150\ underflow before quotient NaN, added GPU test cases for both (including the \-151\ vs \-150\ boundary), re-ran the full test suite (753 passed, 0 failed, 41 ignored) and refreshed the 60 s smoke block.
akimfomin commented 2026-11-24 14:06:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-24T13:47:21Z.


PortBridge linked this to Lyrnc’s gfx1036 probe in VIctory #200 and Continued #762’s translator tests. I compiled the exact div_fixup helper from 2aa8211 in an isolated dispatch and read its output on WARP (DXC 1.9.2602.17).

  • With (q,d,n)=(0x40000000,0x5d800000,0x12000000) the exponent difference is −151. The helper returned 0x40000000; the AMD probe and Continued returned 0x00000000.
  • Replacing n with 0x12800000 gives −150. All three preserved 0x40000000.

Across 14 vectors, including 10 from the hardware probe, the Continued translator plus CPU interpreter matched 14/14. The exact XCL helper matched 9/14. A local HLSL control that prioritizes numerator NaN and applies exp(n)-exp(d)<-150 before handling quotient NaN matched all 14 on WARP. This was a helper-level check. PortBridge case. Synthetic inputs, AI-assisted with Codex.

I independently reran the same WARP probe on the published fix at eac652c. It matched 14/14 on the original vectors, up from 9/14 on 2aa8211. I also replayed the 17 rows in the updated gpu_div_fixup_f32_special_cases_and_sign fixture through the isolated helper. The updated helper matched 17/17, including the NaN payload checks and both signed zero cases, up from 13/17 on the earlier helper. Thanks for adding the regression cases.

<!-- greyfinch-sync:ivall/xcl:comment:7133338458 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7133338458). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-24T13:47:21Z. --- [PortBridge](https://github.com/akimfomin/PortBridge) linked this to [Lyrnc’s gfx1036 probe in VIctory #200](https://github.com/Marvisak/VIctory/pull/200#issuecomment-7123455468) and [Continued #762’s translator tests](https://github.com/ubiquitarianism/leonida/pull/762). I compiled the exact `div_fixup` helper from `2aa8211` in an isolated dispatch and read its output on WARP (DXC 1.9.2602.17). - With `(q,d,n)=(0x40000000,0x5d800000,0x12000000)` the exponent difference is −151. The helper returned `0x40000000`; the AMD probe and Continued returned `0x00000000`. - Replacing `n` with `0x12800000` gives −150. All three preserved `0x40000000`. Across 14 vectors, including 10 from the hardware probe, the Continued translator plus CPU interpreter matched 14/14. The exact XCL helper matched 9/14. A local HLSL control that prioritizes numerator NaN and applies `exp(n)-exp(d)<-150` before handling quotient NaN matched all 14 on WARP. This was a helper-level check. [PortBridge case](https://akimfomin.github.io/PortBridge/cases/pb-0012.html). Synthetic inputs, AI-assisted with Codex. I independently reran the same WARP probe on the published fix at `eac652c`. It matched 14/14 on the original vectors, up from 9/14 on `2aa8211`. I also replayed the 17 rows in the updated `gpu_div_fixup_f32_special_cases_and_sign` fixture through the isolated helper. The updated helper matched 17/17, including the NaN payload checks and both signed zero cases, up from 13/17 on the earlier helper. Thanks for adding the regression cases.
JoaoPauluu commented 2026-11-24 14:06:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T14:05:27Z.


A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. eac652c as it is (based on 930e8b4), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • gpu::recomp::tests::gpu_div_fmas_f32_scales_by_vcc: ok, no SKIPPED.
  • gpu::recomp::tests::gpu_div_fixup_f32_special_cases_and_sign: ok, no SKIPPED.

Not tested

  • whether the new tests fail without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
<!-- greyfinch-sync:ivall/xcl:comment:7133823866 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7133823866). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-24T14:05:27Z. --- A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `eac652c` as it is (based on `930e8b4`), no uncommitted changes. The lib test binary runs under Wine, one test per process (`--exact`). - `gpu::recomp::tests::gpu_div_fmas_f32_scales_by_vcc`: **ok**, no SKIPPED. - `gpu::recomp::tests::gpu_div_fixup_f32_special_cases_and_sign`: **ok**, no SKIPPED. **Not tested** - whether the new tests fail without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64. **AI use** - Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
TobiasFornell commented 2026-11-24 15:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by TobiasFornell on 2026-11-24T14:11:48Z.


Re-tested the updated head eac652c (merged onto main 47efa2e, clean) on the same AMD setup: RX 9070 XT (RDNA4, native wave64), RADV 26.3.1, Proton Experimental 11.0-20261112 Wine, vkd3d-proton v3.1 (scripts/linux build), release.

  • gpu_div_fixup_f32_special_cases_and_sign (incl. the new −151/−150 underflow and NaN-order cases), gpu_div_fmas_f32_scales_by_vcc, gpu_divergence_through_exec: 3 passed, 0 failed, native wave64 path included.

Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.

<!-- greyfinch-sync:ivall/xcl:comment:7133989053 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1144#issuecomment-7133989053). Originally posted by [TobiasFornell](https://github.com/TobiasFornell) on 2026-11-24T14:11:48Z. --- Re-tested the updated head `eac652c` (merged onto `main` `47efa2e`, clean) on the same AMD setup: RX 9070 XT (RDNA4, native wave64), RADV 26.3.1, Proton Experimental `11.0-20261112` Wine, vkd3d-proton v3.1 (`scripts/linux` build), release. - `gpu_div_fixup_f32_special_cases_and_sign` (incl. the new −151/−150 underflow and NaN-order cases), `gpu_div_fmas_f32_scales_by_vcc`, `gpu_divergence_through_exec`: **3 passed, 0 failed**, native wave64 path included. *Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.*
regiumlepidi commented 2026-11-25 00:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by regiumlepidi on 2026-11-24T23:42:15Z.


RTX 5070 Ti: eac652c merged into main 20cf130 passes its two tests on the default path; both still fail with XCL_DIRECT_DXIL=1

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (32-lane waves), driver 617.42; Ryzen 7 9800X3D; Windows 11 Pro 26H2, build 26300.9974; Rust 1.100.0 MSVC; Windows SDK 10.0.26100.0, DXC 1.8.2502.11; debug; no XCL_SAMPLE_*
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture, one run per cell; PR head eac652c3d11927169ea46739249ebcc188ad800e merged locally into 20cf13022f764208384c610c2ae6a3f4eed201a2, no conflicts (passed / failed / ignored):
tree default XCL_DIRECT_DXIL=1
main 20cf130 972 / 4 / 45 971 / 5 / 45
merge 974 / 4 / 45 971 / 7 / 45
  • Default path: gpu_div_fmas_f32_scales_by_vcc and gpu_div_fixup_f32_special_cases_and_sign pass. The 4 failures are fuzz_validate_and_gpu_0 to _3, which fail the same way on main with this driver (#1905)
  • XCL_DIRECT_DXIL=1: those 4, offline_compute_pipeline_is_reused_by_a_second_process (fails on main too), and both new tests:
    • gpu_div_fmas_f32_scales_by_vcc: wave32 lane 1 (vcc=true), left 1088421888, right 1356857344
    • gpu_div_fixup_f32_special_cases_and_sign: wave32 lane 0 v_div_fixup_f32(q=0x7fc00000, d=0x1e3ce508, n=0x7e967699) = 0x7fc00000, want 0x7f800000
  • Negative control, only the PR's tests.rs changes applied to main 20cf130: both new tests fail on both paths with the values above
  • So with XCL_DIRECT_DXIL=1 the merged tree returns the same values for these two cases as main does (the PR's diff touches recomp/emit.rs and recomp/tests.rs)
  • 25 SKIPPED lines in the default run, 18 of them no wave64; none names the new tests

Not tested

  • the wave64 half of the new tests (gpu_waves() runs wave32 only on this adapter), release build, any retail title, other GPUs or drivers

AI use

  • Claude Code with Claude Sonnet 5.5: read the diff, ran the tests and wrote this report.
<!-- greyfinch-sync:ivall/xcl:comment:7147701039 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7147701039). Originally posted by [regiumlepidi](https://github.com/regiumlepidi) on 2026-11-24T23:42:15Z. --- **RTX 5070 Ti: `eac652c` merged into `main` `20cf130` passes its two tests on the default path; both still fail with `XCL_DIRECT_DXIL=1`** **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (32-lane waves), driver 617.42; Ryzen 7 9800X3D; Windows 11 Pro 26H2, build 26300.9974; Rust 1.100.0 MSVC; Windows SDK 10.0.26100.0, DXC 1.8.2502.11; debug; no `XCL_SAMPLE_*` - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture`, one run per cell; PR head `eac652c3d11927169ea46739249ebcc188ad800e` merged locally into `20cf13022f764208384c610c2ae6a3f4eed201a2`, no conflicts (passed / failed / ignored): | tree | default | `XCL_DIRECT_DXIL=1` | |---|---|---| | `main` `20cf130` | 972 / 4 / 45 | 971 / 5 / 45 | | merge | 974 / 4 / 45 | 971 / 7 / 45 | - Default path: `gpu_div_fmas_f32_scales_by_vcc` and `gpu_div_fixup_f32_special_cases_and_sign` pass. The 4 failures are `fuzz_validate_and_gpu_0` to `_3`, which fail the same way on `main` with this driver (#1905) - `XCL_DIRECT_DXIL=1`: those 4, `offline_compute_pipeline_is_reused_by_a_second_process` (fails on `main` too), **and both new tests**: - `gpu_div_fmas_f32_scales_by_vcc`: `wave32 lane 1 (vcc=true)`, left `1088421888`, right `1356857344` - `gpu_div_fixup_f32_special_cases_and_sign`: `wave32 lane 0 v_div_fixup_f32(q=0x7fc00000, d=0x1e3ce508, n=0x7e967699) = 0x7fc00000, want 0x7f800000` - Negative control, only the PR's `tests.rs` changes applied to `main` `20cf130`: both new tests fail on both paths with the values above - So with `XCL_DIRECT_DXIL=1` the merged tree returns the same values for these two cases as `main` does (the PR's diff touches `recomp/emit.rs` and `recomp/tests.rs`) - 25 `SKIPPED` lines in the default run, 18 of them no wave64; none names the new tests **Not tested** - the wave64 half of the new tests (`gpu_waves()` runs wave32 only on this adapter), release build, any retail title, other GPUs or drivers **AI use** - Claude Code with Claude Sonnet 5.5: read the diff, ran the tests and wrote this report.
regiumlepidi commented 2026-11-25 00:09:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by regiumlepidi on 2026-11-25T00:00:48Z.


@b3IKK as in my report above, this PR's two tests still fail with XCL_DIRECT_DXIL=1: the direct translator has the same two bugs in dxil/lower_valu.rs and dxil/prelude.rs. I wrote the matching change for it (below): v_div_fmas_f32 scales by 2^32 where VCC is set (also in programs that direct f32 rounding), and div_fixup works on the bits in the same order as your HLSL helper.

Measured on an RTX 5070 Ti, driver 617.42, debug, with this PR's commit and the patch on main 62265d3: both new tests pass with and without XCL_DIRECT_DXIL=1; cargo test --workspace --locked --no-fail-fast -- --test-threads=4 gives 984 / 4 / 45 (default) and 983 / 5 / 45 (direct), the failures being the four fuzz_validate_and_gpu_* of #1905 and, on direct, offline_compute_pipeline_is_reused_by_a_second_process, which fail on main here too. Not tested: wave64, a v_div_fmas_f32 in a directed-rounding program, any retail title.

Take it into this PR if you like, or say if you would rather it go in a separate PR stacked on this one.

Patch for the direct translator (applies with git apply on this PR merged into main 8e87fc7)
diff --git a/crates/xcl/src/gpu/dxil/lower_valu.rs b/crates/xcl/src/gpu/dxil/lower_valu.rs
index beafdcd..10898fe 100644
--- a/crates/xcl/src/gpu/dxil/lower_valu.rs
+++ b/crates/xcl/src/gpu/dxil/lower_valu.rs
@@ -627,10 +627,16 @@ impl Lw {
                     _ => self.fma_legacy(x, y, cf),
                 })
             }
-            "v_fma_f32" | "v_mad_f32" | "v_fma_legacy_f32" | "v_div_fmas_f32" => {
+            "v_div_fmas_f32" => {
+                let (x, y, w) = (fs!(0), fs!(1), fs!(2));
+                let e = self.fmad(x, y, w);
+                let e = self.div_fmas_scale(&u, e)?;
+                fr!(e)
+            }
+            "v_fma_f32" | "v_mad_f32" | "v_fma_legacy_f32" => {
                 let (x, y, w) = (fs!(0), fs!(1), fs!(2));
                 fr!(match name {
-                    "v_fma_f32" | "v_div_fmas_f32" => self.fmad(x, y, w),
+                    "v_fma_f32" => self.fmad(x, y, w),
                     "v_mad_f32" => self.mad_nf(x, y, w),
                     _ => self.fma_legacy(x, y, w),
                 })
@@ -664,8 +670,10 @@ impl Lw {
                 fr!(self.cube(name, x, y, w))
             }
             "v_div_fixup_f32" => {
-                let (q, dd, nn) = (fs!(0), fs!(1), fs!(2));
-                fr!(self.div_fixup(q, dd, nn))
+                // on the bits: NaN payloads and denormal operands reach the checks unchanged
+                let (q, dd, nn) = (self.fsrc_bits(&m, 0, a), self.fsrc_bits(&m, 1, b), self.fsrc_bits(&m, 2, c));
+                let r = self.div_fixup(q, dd, nn);
+                fr!(self.f(r))
             }
             // clamp: unsigned saturation
             "v_add_nc_u32" | "v_add3_u32" if m.clamp => {
@@ -1061,6 +1069,15 @@ impl Lw {
         Ok(())
     }
 
+    /// `v_div_fmas_f32`: the fma result scaled by 2^32 in lanes whose VCC bit (source 3) is set.
+    fn div_fmas_scale(&mut self, u: &[Src], e: Value) -> LResult<Value> {
+        let Some(Src::Pair(l, h)) = u.get(3).copied() else { return Err("v_div_fmas_f32: VCC".into()) };
+        let bit = self.lane_of(l, h);
+        let k = self.c(32);
+        let scaled = self.ldexp_f(e, k);
+        Ok(self.sel(bit, scaled, e))
+    }
+
     /// Source bits with abs / neg applied on the bits (no float operation: denormals stay).
     fn fsrc_bits(&mut self, m: &Mods, i: usize, u: Value) -> Value {
         let mut s = u;
@@ -1114,10 +1131,15 @@ impl Lw {
                 let zz = self.fc(0.0);
                 self.sel(lz, zz, r)
             }
-            "v_fma_f32" | "v_div_fmas_f32" => {
+            "v_fma_f32" => {
                 let n = self.fmad(fa, fb, fc);
                 self.rm_fma(ba, bb, bc, n)
             }
+            "v_div_fmas_f32" => {
+                let n = self.fmad(fa, fb, fc);
+                let r = self.rm_fma(ba, bb, bc, n);
+                self.div_fmas_scale(u, r)?
+            }
             "v_fma_legacy_f32" => {
                 let n = self.fmad(fa, fb, fc);
                 let r = self.rm_fma(ba, bb, bc, n);
diff --git a/crates/xcl/src/gpu/dxil/prelude.rs b/crates/xcl/src/gpu/dxil/prelude.rs
index a171fd0..08a9d1a 100644
--- a/crates/xcl/src/gpu/dxil/prelude.rs
+++ b/crates/xcl/src/gpu/dxil/prelude.rs
@@ -192,20 +192,44 @@ impl Lw {
         let y = self.fmin(y, c);
         self.fmax(x, y)
     }
-    /// `div_fixup`
+    /// `div_fixup` on f32 bits (quotient, denominator, numerator), as the HLSL path's helper:
+    /// NaN (numerator first), 0/0 and Inf/Inf, x/0 and Inf/x, x/Inf and 0/x, underflow when
+    /// exp(n) - exp(d) < -150, a NaN quotient as overflow, and the sign sign(d) ^ sign(n).
     pub fn div_fixup(&mut self, q: Value, d: Value, n: Value) -> Value {
-        let a = self.isnan(d);
-        let b = self.isnan(n);
-        let z = self.fc(0.0);
-        let dz = self.fcmp(Pred::FOEq, d, z);
-        let di = self.isinf(d);
-        let ni = self.isinf(n);
-        let x = self.lor(a, b);
-        let y = self.lor(di, ni);
-        let y = self.lor(dz, y);
-        let c = self.lor(x, y);
-        let r = self.fdiv(n, d);
-        self.sel(c, r, q)
+        let sign = self.xor(d, n);
+        let sign = self.andc(sign, 0x8000_0000);
+        let (qa, da, na) = (self.andc(q, 0x7FFF_FFFF), self.andc(d, 0x7FFF_FFFF), self.andc(n, 0x7FFF_FFFF));
+        let inf = self.orc(sign, 0x7F80_0000);
+        // lowest priority first: each select overrides the ones before it
+        let r = self.or(sign, qa);
+        let qnan = self.cmpc(Pred::UGt, qa, 0x7F80_0000);
+        let r = self.sel(qnan, inf, r);
+        let en = self.lshrc(n, 23);
+        let en = self.andc(en, 0xFF);
+        let ed = self.lshrc(d, 23);
+        let ed = self.andc(ed, 0xFF);
+        let diff = self.sub(en, ed);
+        let under = self.cmpc(Pred::SLt, diff, -150i32 as u32);
+        let r = self.sel(under, sign, r);
+        let dinf = self.cmpc(Pred::Eq, da, 0x7F80_0000);
+        let ninf = self.cmpc(Pred::Eq, na, 0x7F80_0000);
+        let dz = self.cmpc(Pred::Eq, da, 0);
+        let nz = self.cmpc(Pred::Eq, na, 0);
+        let to_zero = self.lor(dinf, nz);
+        let r = self.sel(to_zero, sign, r);
+        let to_inf = self.lor(dz, ninf);
+        let r = self.sel(to_inf, inf, r);
+        let zz = self.land(dz, nz);
+        let ii = self.land(dinf, ninf);
+        let invalid = self.lor(zz, ii);
+        let k = self.c(0xFFC0_0000);
+        let r = self.sel(invalid, k, r);
+        let dnan = self.cmpc(Pred::UGt, da, 0x7F80_0000);
+        let dq = self.orc(d, 0x0040_0000);
+        let r = self.sel(dnan, dq, r);
+        let nnan = self.cmpc(Pred::UGt, na, 0x7F80_0000);
+        let nq = self.orc(n, 0x0040_0000);
+        self.sel(nnan, nq, r)
     }
     /// cube_id / cube_sc / cube_tc / cube_ma
     pub fn cube(&mut self, name: &str, x: Value, y: Value, z: Value) -> Value {

Claude Code with Claude Opus 5.5 wrote the patch, ran the tests and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7148039461 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7148039461). Originally posted by [regiumlepidi](https://github.com/regiumlepidi) on 2026-11-25T00:00:48Z. --- @b3IKK as in my report above, this PR's two tests still fail with `XCL_DIRECT_DXIL=1`: the direct translator has the same two bugs in `dxil/lower_valu.rs` and `dxil/prelude.rs`. I wrote the matching change for it (below): `v_div_fmas_f32` scales by 2^32 where VCC is set (also in programs that direct f32 rounding), and `div_fixup` works on the bits in the same order as your HLSL helper. Measured on an RTX 5070 Ti, driver 617.42, debug, with this PR's commit and the patch on `main` `62265d3`: both new tests pass with and without `XCL_DIRECT_DXIL=1`; `cargo test --workspace --locked --no-fail-fast -- --test-threads=4` gives 984 / 4 / 45 (default) and 983 / 5 / 45 (direct), the failures being the four `fuzz_validate_and_gpu_*` of #1905 and, on direct, `offline_compute_pipeline_is_reused_by_a_second_process`, which fail on `main` here too. Not tested: wave64, a `v_div_fmas_f32` in a directed-rounding program, any retail title. Take it into this PR if you like, or say if you would rather it go in a separate PR stacked on this one. <details><summary>Patch for the direct translator (applies with <code>git apply</code> on this PR merged into <code>main</code> <code>8e87fc7</code>)</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/lower_valu.rs b/crates/xcl/src/gpu/dxil/lower_valu.rs index beafdcd..10898fe 100644 --- a/crates/xcl/src/gpu/dxil/lower_valu.rs +++ b/crates/xcl/src/gpu/dxil/lower_valu.rs @@ -627,10 +627,16 @@ impl Lw { _ => self.fma_legacy(x, y, cf), }) } - "v_fma_f32" | "v_mad_f32" | "v_fma_legacy_f32" | "v_div_fmas_f32" => { + "v_div_fmas_f32" => { + let (x, y, w) = (fs!(0), fs!(1), fs!(2)); + let e = self.fmad(x, y, w); + let e = self.div_fmas_scale(&u, e)?; + fr!(e) + } + "v_fma_f32" | "v_mad_f32" | "v_fma_legacy_f32" => { let (x, y, w) = (fs!(0), fs!(1), fs!(2)); fr!(match name { - "v_fma_f32" | "v_div_fmas_f32" => self.fmad(x, y, w), + "v_fma_f32" => self.fmad(x, y, w), "v_mad_f32" => self.mad_nf(x, y, w), _ => self.fma_legacy(x, y, w), }) @@ -664,8 +670,10 @@ impl Lw { fr!(self.cube(name, x, y, w)) } "v_div_fixup_f32" => { - let (q, dd, nn) = (fs!(0), fs!(1), fs!(2)); - fr!(self.div_fixup(q, dd, nn)) + // on the bits: NaN payloads and denormal operands reach the checks unchanged + let (q, dd, nn) = (self.fsrc_bits(&m, 0, a), self.fsrc_bits(&m, 1, b), self.fsrc_bits(&m, 2, c)); + let r = self.div_fixup(q, dd, nn); + fr!(self.f(r)) } // clamp: unsigned saturation "v_add_nc_u32" | "v_add3_u32" if m.clamp => { @@ -1061,6 +1069,15 @@ impl Lw { Ok(()) } + /// `v_div_fmas_f32`: the fma result scaled by 2^32 in lanes whose VCC bit (source 3) is set. + fn div_fmas_scale(&mut self, u: &[Src], e: Value) -> LResult<Value> { + let Some(Src::Pair(l, h)) = u.get(3).copied() else { return Err("v_div_fmas_f32: VCC".into()) }; + let bit = self.lane_of(l, h); + let k = self.c(32); + let scaled = self.ldexp_f(e, k); + Ok(self.sel(bit, scaled, e)) + } + /// Source bits with abs / neg applied on the bits (no float operation: denormals stay). fn fsrc_bits(&mut self, m: &Mods, i: usize, u: Value) -> Value { let mut s = u; @@ -1114,10 +1131,15 @@ impl Lw { let zz = self.fc(0.0); self.sel(lz, zz, r) } - "v_fma_f32" | "v_div_fmas_f32" => { + "v_fma_f32" => { let n = self.fmad(fa, fb, fc); self.rm_fma(ba, bb, bc, n) } + "v_div_fmas_f32" => { + let n = self.fmad(fa, fb, fc); + let r = self.rm_fma(ba, bb, bc, n); + self.div_fmas_scale(u, r)? + } "v_fma_legacy_f32" => { let n = self.fmad(fa, fb, fc); let r = self.rm_fma(ba, bb, bc, n); diff --git a/crates/xcl/src/gpu/dxil/prelude.rs b/crates/xcl/src/gpu/dxil/prelude.rs index a171fd0..08a9d1a 100644 --- a/crates/xcl/src/gpu/dxil/prelude.rs +++ b/crates/xcl/src/gpu/dxil/prelude.rs @@ -192,20 +192,44 @@ impl Lw { let y = self.fmin(y, c); self.fmax(x, y) } - /// `div_fixup` + /// `div_fixup` on f32 bits (quotient, denominator, numerator), as the HLSL path's helper: + /// NaN (numerator first), 0/0 and Inf/Inf, x/0 and Inf/x, x/Inf and 0/x, underflow when + /// exp(n) - exp(d) < -150, a NaN quotient as overflow, and the sign sign(d) ^ sign(n). pub fn div_fixup(&mut self, q: Value, d: Value, n: Value) -> Value { - let a = self.isnan(d); - let b = self.isnan(n); - let z = self.fc(0.0); - let dz = self.fcmp(Pred::FOEq, d, z); - let di = self.isinf(d); - let ni = self.isinf(n); - let x = self.lor(a, b); - let y = self.lor(di, ni); - let y = self.lor(dz, y); - let c = self.lor(x, y); - let r = self.fdiv(n, d); - self.sel(c, r, q) + let sign = self.xor(d, n); + let sign = self.andc(sign, 0x8000_0000); + let (qa, da, na) = (self.andc(q, 0x7FFF_FFFF), self.andc(d, 0x7FFF_FFFF), self.andc(n, 0x7FFF_FFFF)); + let inf = self.orc(sign, 0x7F80_0000); + // lowest priority first: each select overrides the ones before it + let r = self.or(sign, qa); + let qnan = self.cmpc(Pred::UGt, qa, 0x7F80_0000); + let r = self.sel(qnan, inf, r); + let en = self.lshrc(n, 23); + let en = self.andc(en, 0xFF); + let ed = self.lshrc(d, 23); + let ed = self.andc(ed, 0xFF); + let diff = self.sub(en, ed); + let under = self.cmpc(Pred::SLt, diff, -150i32 as u32); + let r = self.sel(under, sign, r); + let dinf = self.cmpc(Pred::Eq, da, 0x7F80_0000); + let ninf = self.cmpc(Pred::Eq, na, 0x7F80_0000); + let dz = self.cmpc(Pred::Eq, da, 0); + let nz = self.cmpc(Pred::Eq, na, 0); + let to_zero = self.lor(dinf, nz); + let r = self.sel(to_zero, sign, r); + let to_inf = self.lor(dz, ninf); + let r = self.sel(to_inf, inf, r); + let zz = self.land(dz, nz); + let ii = self.land(dinf, ninf); + let invalid = self.lor(zz, ii); + let k = self.c(0xFFC0_0000); + let r = self.sel(invalid, k, r); + let dnan = self.cmpc(Pred::UGt, da, 0x7F80_0000); + let dq = self.orc(d, 0x0040_0000); + let r = self.sel(dnan, dq, r); + let nnan = self.cmpc(Pred::UGt, na, 0x7F80_0000); + let nq = self.orc(n, 0x0040_0000); + self.sel(nnan, nq, r) } /// cube_id / cube_sc / cube_tc / cube_ma pub fn cube(&mut self, name: &str, x: Value, y: Value, z: Value) -> Value { ``` </details> _Claude Code with Claude Opus 5.5 wrote the patch, ran the tests and wrote this comment._
luckyteagirl commented 2026-11-25 04:10:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T03:32:43Z.


Tested

  • Exact PR head eac652c3d11927169ea46739249ebcc188ad800e on Windows 11 build 26200, AMD Radeon RX 6800M (driver 30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. XCL_ADAPTER=6800M and XCL_REQUIRE_GPU=1 were set.
  • cargo test --locked -p xcl --lib -j 2 gpu_div_fmas_f32_scales_by_vcc -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, no explicit skip.
  • The same command with filter gpu_div_fixup_f32_special_cases_and_sign: 1 passed, 0 failed, 0 ignored, no explicit skip. This test includes 17 NaN, zero, infinity, sign, and exponent-boundary cases.

Coverage note

Both tests call gpu_waves() and run_wave(). The latter translates to HLSL with Options { wave64, ..Default::default() }; neither test sets split_wave64: true. Thus these runs establish HLSL GPU coverage on AMD, but the current tests do not explicitly exercise split wave64, despite the PR description's claim. They run wave32 and, if the adapter reports native wave64, native wave64. I did not instrument which native mode the adapter chose.

Not tested

  • Direct DXIL, split wave64, the full workspace suite, another GPU, or a retail title.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff and test helpers, ran both focused GPU tests, checked the logs, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7152013648 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7152013648). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T03:32:43Z. --- **Tested** - Exact PR head `eac652c3d11927169ea46739249ebcc188ad800e` on Windows 11 build 26200, AMD Radeon RX 6800M (driver `30.0.13002.13003`), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. `XCL_ADAPTER=6800M` and `XCL_REQUIRE_GPU=1` were set. - `cargo test --locked -p xcl --lib -j 2 gpu_div_fmas_f32_scales_by_vcc -- --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored**, no explicit skip. - The same command with filter `gpu_div_fixup_f32_special_cases_and_sign`: **1 passed, 0 failed, 0 ignored**, no explicit skip. This test includes 17 NaN, zero, infinity, sign, and exponent-boundary cases. **Coverage note** Both tests call `gpu_waves()` and `run_wave()`. The latter translates to HLSL with `Options { wave64, ..Default::default() }`; neither test sets `split_wave64: true`. Thus these runs establish HLSL GPU coverage on AMD, but the current tests do **not explicitly exercise split wave64**, despite the PR description's claim. They run wave32 and, if the adapter reports native wave64, native wave64. I did not instrument which native mode the adapter chose. **Not tested** - Direct DXIL, split wave64, the full workspace suite, another GPU, or a retail title. **AI use** OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff and test helpers, ran both focused GPU tests, checked the logs, and drafted this report.
JJAutoCompare commented 2026-11-25 04:10:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:54:15Z.


PR #1144 on Intel Arc A770

Tested

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175. Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc), unoptimized test profile with debuginfo disabled. Both test stderr logs confirmed loaded DXC and DXIL 1.9.2609.5.
  • The open PR #1144 and the clean detached checkout matched eac652c3d11927169ea46739249ebcc188ad800e before and after the run. Upstream AGENTS.md and CONTRIBUTING.md were read from main at cbc296ab65a2661a61e3e2da109134bcd5319f60. I found no equivalent Arc result in the PR discussion or issue #42.
  • cargo test --locked -p xcl --lib --no-run succeeded outside the Arc mutex. CARGO_TARGET_DIR=L:/XclTooling/pr1512-tiling-edges-fddfa267/target, CARGO_BUILD_JOBS=2, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0. TEMP and TMP pointed at L:/XclTooling/pr1144/run-20261125T034636736Z/temp.
  • Each command below ran in its own powershell.exe -NoProfile -ExecutionPolicy RemoteSigned process under & 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }, with XCL_ADAPTER=A770 and XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. The build, each test executable invocation, and each mutex wrapper have separate stdout and stderr files next to this report.
$exe = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe'
& $exe gpu::recomp::tests::gpu_div_fmas_f32_scales_by_vcc --exact --nocapture --test-threads=1
& $exe gpu::recomp::tests::gpu_div_fixup_f32_special_cases_and_sign --exact --nocapture --test-threads=1
Fixture Passed Failed Ignored Explicit skips Filtered out Exit Time
gpu_div_fmas_f32_scales_by_vcc 1 0 0 0 729 0 0.19 s
gpu_div_fixup_f32_special_cases_and_sign 1 0 0 0 729 0 0.16 s

The first invocation of each fixture also reported a pass, and both mutex releases were logged. PowerShell's Start-Process lost access to the exit status of the fast child processes. I reran the same two fixtures with exit status captured through System.Diagnostics.Process. The table uses the reruns and their .verified.* logs. Both reruns acquired and released the Arc mutex.

Both fixtures assemble synthetic RDNA2 instructions and run HLSL compiled by DXC for cs_6_6. gpu_waves() selects wave32 and adds a native wave64 run only when the adapter exposes 64 lanes. The A770 with this driver reports an 8–32 lane range in the existing D3D12 probe, so coverage here was wave32. kernel_wave() leaves split_wave64 at its default false for both fixtures. Arc A770 capability probe

  • FMAS compared 64 output words bit-for-bit across 32 lanes. For 2 × 3 + 1, the 16 even lanes with VCC clear returned 7.0 and the 16 odd lanes with VCC set returned 7.0 × 2^32. A second instruction checked positive zero in all 32 lanes under the same VCC pattern.
  • FIXUP checked 32 lanes cycling through 17 distinct (q, d, n) vectors. They cover signed infinity for a NaN quotient on overflow, signed zeros and infinities for zero or infinite operands, finite sign correction, NaN classification for 0/0 and Inf/Inf, exact quiet-NaN payloads with numerator priority, and the exponent-difference boundary at −151 and −150. The −151 rows include both signs of zero and precedence over a NaN quotient. At −150 the supplied finite quotient is preserved.

Not tested

  • Native or split wave64, direct DXIL, other GPUs or drivers, the broader suite, and retail-title smoke runs.

AI use

  • T3 Code / Codex (gpt-6.2-sol) checked the PR and stock fixtures, ran the tests, and wrote this report.
<!-- greyfinch-sync:ivall/xcl:comment:7152347202 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7152347202). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T03:54:15Z. --- # PR #1144 on Intel Arc A770 **Tested** - STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175. Rust and Cargo 1.100.0 (`x86_64-pc-windows-msvc`), unoptimized test profile with debuginfo disabled. Both test stderr logs confirmed loaded DXC and DXIL 1.9.2609.5. - The open [PR #1144](https://github.com/xcl-dev/xcl/pull/1144) and the clean detached checkout matched `eac652c3d11927169ea46739249ebcc188ad800e` before and after the run. Upstream `AGENTS.md` and `CONTRIBUTING.md` were read from `main` at `cbc296ab65a2661a61e3e2da109134bcd5319f60`. I found no equivalent Arc result in the PR discussion or issue #42. - `cargo test --locked -p xcl --lib --no-run` succeeded outside the Arc mutex. `CARGO_TARGET_DIR=L:/XclTooling/pr1512-tiling-edges-fddfa267/target`, `CARGO_BUILD_JOBS=2`, `CARGO_INCREMENTAL=0`, `CARGO_PROFILE_DEV_DEBUG=0`, `CARGO_PROFILE_TEST_DEBUG=0`. `TEMP` and `TMP` pointed at `L:/XclTooling/pr1144/run-20261125T034636736Z/temp`. - Each command below ran in its own `powershell.exe -NoProfile -ExecutionPolicy RemoteSigned` process under `& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }`, with `XCL_ADAPTER=A770` and `XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64`. The build, each test executable invocation, and each mutex wrapper have separate stdout and stderr files next to this report. ```powershell $exe = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' & $exe gpu::recomp::tests::gpu_div_fmas_f32_scales_by_vcc --exact --nocapture --test-threads=1 & $exe gpu::recomp::tests::gpu_div_fixup_f32_special_cases_and_sign --exact --nocapture --test-threads=1 ``` | Fixture | Passed | Failed | Ignored | Explicit skips | Filtered out | Exit | Time | |---|---:|---:|---:|---:|---:|---:|---:| | `gpu_div_fmas_f32_scales_by_vcc` | 1 | 0 | 0 | 0 | 729 | 0 | 0.19 s | | `gpu_div_fixup_f32_special_cases_and_sign` | 1 | 0 | 0 | 0 | 729 | 0 | 0.16 s | The first invocation of each fixture also reported a pass, and both mutex releases were logged. PowerShell's `Start-Process` lost access to the exit status of the fast child processes. I reran the same two fixtures with exit status captured through `System.Diagnostics.Process`. The table uses the reruns and their `.verified.*` logs. Both reruns acquired and released the Arc mutex. Both fixtures assemble synthetic RDNA2 instructions and run HLSL compiled by DXC for `cs_6_6`. `gpu_waves()` selects wave32 and adds a native wave64 run only when the adapter exposes 64 lanes. The A770 with this driver reports an 8–32 lane range in the existing D3D12 probe, so coverage here was wave32. `kernel_wave()` leaves `split_wave64` at its default `false` for both fixtures. [Arc A770 capability probe](https://github.com/xcl-dev/xcl/issues/42#issuecomment-7148783002) - FMAS compared 64 output words bit-for-bit across 32 lanes. For `2 × 3 + 1`, the 16 even lanes with VCC clear returned `7.0` and the 16 odd lanes with VCC set returned `7.0 × 2^32`. A second instruction checked positive zero in all 32 lanes under the same VCC pattern. - FIXUP checked 32 lanes cycling through 17 distinct `(q, d, n)` vectors. They cover signed infinity for a NaN quotient on overflow, signed zeros and infinities for zero or infinite operands, finite sign correction, NaN classification for `0/0` and `Inf/Inf`, exact quiet-NaN payloads with numerator priority, and the exponent-difference boundary at −151 and −150. The −151 rows include both signs of zero and precedence over a NaN quotient. At −150 the supplied finite quotient is preserved. **Not tested** - Native or split wave64, direct DXIL, other GPUs or drivers, the broader suite, and retail-title smoke runs. **AI use** - T3 Code / Codex (`gpt-6.2-sol`) checked the PR and stock fixtures, ran the tests, and wrote this report.
DavidM1911 commented 2026-11-26 04:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:40:59Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7181932370 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7181932370). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T03:40:59Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
KDenKC commented 2026-11-27 06:50:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-27T06:50:36Z.


@b3IKK, a heads-up on v_div_fmas_f32 in eac652c3, which also applies to @regiumlepidi's direct-DXIL version (7148039461) and to the patch in #2952 (7209397473). All three scale by 2^32 (ldexp_f(..., 32)) when VCC is set, following the RDNA 2/3 ISA PDF's 2.0F ** 32 * fma(S0, S1, S2).

That PDF line appears to be wrong for the hardware:

  • tinygrad's AMD hardware tests (MIT) run the same vector as gpu_div_fmas_f32_scales_by_vcc: S0 = 2.0, S1 = 3.0, S2 = 1.0, VCC set. They expect 7.0 * 2^-64, not 7.0 * 2^32 (test_vop3.py test_div_fmas_f32_scale_down). With S2 = 2.0 (scale_up), they expect * 2^64.
  • Their emulator carries it as a correction to the PDF pseudo-code (emu.py _pcode_fixes): D0 = exponent(S2) > 127 ? 2^64 * fma(S0,S1,S2) : 2^-64 * fma(S0,S1,S2).
  • That is the factor that undoes v_div_scale_f32's ldexp(.., ±64). A fixed 2^32 leaves any division that takes the scaled path off by 2^32 or 2^96. It doesn't show today only because v_div_scale_f32 never sets VCC in either path.

The div_fixup side of eac652c3 agrees with the same table (isNAN(S0) ? ±INF : ...). Separately, we have a local direct-DXIL change that implements all three (div_scale with its VCC, div_fmas with the ±64 rule applied inside the fused op, and fixup) and checks the whole LLVM fdiv.f32 sequence against the host's IEEE quotient. Its GPU runs are pending. We'll report how it compares, or fold whatever helps into this PR if you prefer.

AI use: Gemini (Antigravity) found the sites and the tinygrad tests; Claude Code (Claude Opus 5.5) checked the test vectors in both trees and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7211897698 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7211897698). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-11-27T06:50:36Z. --- @b3IKK, a heads-up on `v_div_fmas_f32` in `eac652c3`, which also applies to @regiumlepidi's direct-DXIL version (7148039461) and to the patch in #2952 (7209397473). All three scale by `2^32` (`ldexp_f(..., 32)`) when VCC is set, following the RDNA 2/3 ISA PDF's `2.0F ** 32 * fma(S0, S1, S2)`. That PDF line appears to be wrong for the hardware: - tinygrad's AMD hardware tests (MIT) run **the same vector as `gpu_div_fmas_f32_scales_by_vcc`**: `S0 = 2.0, S1 = 3.0, S2 = 1.0`, VCC set. They expect `7.0 * 2^-64`, not `7.0 * 2^32` ([test_vop3.py `test_div_fmas_f32_scale_down`](https://github.com/tinygrad/tinygrad/blob/e3e8be0800075030fb4fb096df3132bfda77a089/test/amd/hw/test_vop3.py#L314-L325)). With `S2 = 2.0` (`scale_up`), they expect `* 2^64`. - Their emulator carries it as a correction to the PDF pseudo-code ([emu.py `_pcode_fixes`](https://github.com/tinygrad/tinygrad/blob/e3e8be0800075030fb4fb096df3132bfda77a089/test/mockgpu/amd/emu.py#L142-L143)): `D0 = exponent(S2) > 127 ? 2^64 * fma(S0,S1,S2) : 2^-64 * fma(S0,S1,S2)`. - That is the factor that undoes `v_div_scale_f32`'s `ldexp(.., ±64)`. A fixed `2^32` leaves any division that takes the scaled path off by `2^32` or `2^96`. It doesn't show today only because `v_div_scale_f32` never sets VCC in either path. The `div_fixup` side of `eac652c3` agrees with the same table (`isNAN(S0) ? ±INF : ...`). Separately, we have a local direct-DXIL change that implements all three (`div_scale` with its VCC, `div_fmas` with the ±64 rule applied inside the fused op, and fixup) and checks the whole LLVM `fdiv.f32` sequence against the host's IEEE quotient. Its GPU runs are pending. We'll report how it compares, or fold whatever helps into this PR if you prefer. AI use: Gemini (Antigravity) found the sites and the tinygrad tests; Claude Code (Claude Opus 5.5) checked the test vectors in both trees and wrote this comment.
Foniass commented 2026-12-01 04:55:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:55:09Z.


Triage (#1607) – head eac652c

#3312 also rewrites the HLSL div_fixup helper in emit.rs, with a different approach. It falls back to n / d for NaN, Inf or zero quotients, scales huge denominators and changes the direct-DXIL prelude as well. This PR implements the per-bit special cases instead (NaN propagation, sign, exponent-difference underflow) and makes v_div_fmas_f32 scale by 2^32 when VCC is set. #823 covers only the f64 ops.
On main, v_div_scale_f32 always writes VCC = 0, so the v_div_fmas_f32 change only matters for VCC set by other code. A quotient that the unscaled sequence flushes to 0 (for example 3e38 / 3e38) still returns 0 here, while #3312 handles that case. The PR conflicts with main.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301235603 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1144#issuecomment-7301235603). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:55:09Z. --- **Triage (#1607)** – head eac652c #3312 also rewrites the HLSL `div_fixup` helper in `emit.rs`, with a different approach. It falls back to `n / d` for NaN, Inf or zero quotients, scales huge denominators and changes the direct-DXIL prelude as well. This PR implements the per-bit special cases instead (NaN propagation, sign, exponent-difference underflow) and makes `v_div_fmas_f32` scale by 2^32 when VCC is set. #823 covers only the f64 ops. On main, `v_div_scale_f32` always writes VCC = 0, so the `v_div_fmas_f32` change only matters for VCC set by other code. A quotient that the unscaled sequence flushes to 0 (for example 3e38 / 3e38) still returns 0 here, while #3312 handles that case. The PR conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1144:upstream-pr/1144'
git switch 'upstream-pr/1144'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1144'
git switch 'upstream-pr/1144'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1144'
git switch 'upstream-pr/1144'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1144'
git switch 'main'
git merge --squash 'upstream-pr/1144'
git switch 'main'
git merge --ff-only 'upstream-pr/1144'
git switch 'main'
git merge 'upstream-pr/1144'
git push origin 'main'
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!1135
No description provided.