Skip to content

[upstream #1144] Recompiler: v_div_fmas_f32 scales by VCC and v_div_fixup_f32 handles NaN/zero/sign - #18

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1144
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1144

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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, and without setting the result sign to sign(d) ^ sign(n). This replaces div_fixup with an IEEE-754 bit-level implementation covering NaN, 0/0, Inf/Inf, x/0, Inf/x, x/Inf, 0/x, 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/zero/inf/sign cases.
  • 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 across wave32 and split wave64 (both 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): 743 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: GTA6.Xbox.v1.0.2.1
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: 2aa8211b9d72243dbe521cb0e0fbea9352dcf0dd
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1334 (PresentX 1334)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14487 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, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

Mirror of xcl-dev#1144 (auto-synced, do not edit).

…NaN/zero/sign

v_div_fmas_f32 emitted mad(s0, s1, s2) and ignored its implicit VCC
operand instead of scaling by 2^32 (ldexp_f(..., 32)) for lanes with
VCC == 1.

div_fixup returned q unchanged when q was NaN (overflow in the quotient
sequence), when n == +-0.0 with finite d, and without forcing the
result sign to sign(d) ^ sign(n). Handle NaN/zero/inf special cases
and sign on the IEEE-754 bits directly, with GPU tests for both
instructions across wave32 and split wave64.

Assisted-by: OpenCode (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1144 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1144 branch November 25, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants