fix(recompiler): fold true unordered comparisons against f32 infinity #3441
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3441"
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?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T10:40:48Z.
What
On current
main,emitFloatCompareemits an unordered floating comparison when one operand is an f32 infinity constant. NVIDIA's shader compiler crashes with SIGILL on four such comparisons reported in #3355, even though each comparison is true for every f32 input.This folds those four constant-infinity forms to true during translation, so they do not emit the floating comparison. The change is limited to f32 unordered less-or-equal/greater-or-equal cases where the constant makes the result unconditional. The issue also reports computed-infinity and f16 cases; those remain open and are outside this change.
Tested
Linux x86_64, GCC 12.2, Release build. The new
vector_compare_constchecks fail against currentmainbecause translation retains the floating compare, and pass with this change.tools/check_conventions.py --base upstream/mainandgit diff --checkpass.A reviewer also built and ran this PR on Windows 11 with WinLibs GCC 15.2.0 r7, an RTX 5060 Laptop GPU (driver 617.42), and an Arrow Lake Intel iGPU (driver 101.8991), with
ANYPS5_NO_SHADER_CACHE=1.agc_driver_f32_compare_constantpassed 3/3 on both GPUs onmainand with this PR;vector_compare_constpassed with this PR. The crash reported in #3355 was not reproduced on this Windows driver, so this verifies no regression there but does not confirm the Linux driver crash is fixed. No PS5 title/homebrew run was available.Checklist
main(0f863c10); no other open PR implements the same comparisonsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebtRelated to #3355
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T11:28:21Z.
Ran this on Windows with an NVIDIA GPU, since the PR had no NVIDIA run: RTX 5060 Laptop (Blackwell, like the 5080 in #3355) on driver 617.42, Windows 11, WinLibs GCC 15.2.0 r7, Release,
ANYPS5_NO_SHADER_CACHE=1.main0f863c10:agc_driver_f32_compare_constantpasses 3/3 on the 5060 and 3/3 on the Arrow Lake iGPU (Intel 101.8991). So this driver doesn't crash on thengt/nltagainst +inf compares, which points at the Linux 615.78 driver in #3355 rather than at Blackwell in general.main+ this PR (85b60b65):agc_driver_f32_compare_constantpasses 3/3 on both GPUs, andvector_compare_constpasses.So I can't confirm the fix against the crash itself here, but it builds and causes no regressions on Windows with either GPU.
AI-assisted (Claude Code); I ran all of this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:55:13Z.
Checked: the four folded forms (
ngt x,+inf,nlt x,-inf,nlt +inf,x,ngt -inf,x) are true for every f32 input, NaN included. Confirmed on the HW oracle (gfx1035, IEEE=0, denorms flushed) over 16 rows: ±0, denormals, ±1, ±FLT_MAX, ±inf, quiet/signalling NaNs. Build + ctest of the touched components pass, andvector_compare_constfails without the change. Not verified here: the NVIDIA Linux crash itself (no NVIDIA GPU); thanks @Silverash-i8 for the Windows runs. Merging.