fix(recompiler): fold true unordered comparisons against f32 infinity #3441

Merged
MarcZX10 merged 1 commit from upstream-pr/3441 into main 2026-10-11 11:55:17 +00:00
MarcZX10 commented 2026-10-11 10:40:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T10:40:48Z.


What

On current main, emitFloatCompare emits 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_const checks fail against current main because translation retains the floating compare, and pass with this change. tools/check_conventions.py --base upstream/main and git diff --check pass.

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_constant passed 3/3 on both GPUs on main and with this PR; vector_compare_const passed 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

  • Based on current main (0f863c10); no other open PR implements the same comparisons
  • One topic per PR; follow-ups go in a new pull request
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

Related to #3355

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818460613 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3441). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T10:40:48Z. --- ### What On current `main`, `emitFloatCompare` emits 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_const` checks fail against current `main` because translation retains the floating compare, and pass with this change. `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. 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_constant` passed 3/3 on both GPUs on `main` and with this PR; `vector_compare_const` passed 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 - [x] Based on current `main` (0f863c10); no other open PR implements the same comparisons - [x] One topic per PR; follow-ups go in a new pull request - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes Related to #3355
Silverash-i8 commented 2026-10-11 11:28:21 +00:00 (Migrated from github.com)

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.

  • main 0f863c10: agc_driver_f32_compare_constant passes 3/3 on the 5060 and 3/3 on the Arrow Lake iGPU (Intel 101.8991). So this driver doesn't crash on the ngt / nlt against +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_constant passes 3/3 on both GPUs, and vector_compare_const passes.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108540187 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3441#issuecomment-6108540187). Originally posted by [Silverash-i8](https://github.com/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`. - `main` 0f863c10: `agc_driver_f32_compare_constant` passes 3/3 on the 5060 and 3/3 on the Arrow Lake iGPU (Intel 101.8991). So this driver doesn't crash on the `ngt` / `nlt` against +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_constant` passes 3/3 on both GPUs, and `vector_compare_const` passes. 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.
adriadam10 commented 2026-10-11 11:55:13 +00:00 (Migrated from github.com)

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, and vector_compare_const fails without the change. Not verified here: the NVIDIA Linux crash itself (no NVIDIA GPU); thanks @Silverash-i8 for the Windows runs. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108753517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3441#issuecomment-6108753517). Originally posted by [adriadam10](https://github.com/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, and `vector_compare_const` fails without the change. Not verified here: the NVIDIA Linux crash itself (no NVIDIA GPU); thanks @Silverash-i8 for the Windows runs. Merging.
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
boykopovar/AnyPS5!3441
No description provided.