fix(shader): translate f32 compares in f32 denormal modes 1 and 2 #6007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6007"
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 zmeizy on 2026-10-14T19:11:24Z.
What
v_cmp_X_f32andv_cmpx_X_f32(X = eq, ge, gt, le, lg, lt, neq, nge, ngt, nle, nlg, nlt) threwf32 denormal mode N ... is not implementedin shaders whoseFLOAT_MODEf32 denormal field (bits 5:4) is 1 or 2. On RDNA2 they flush their denormal inputs only when bit 0 of that field is clear: mode 1 keeps denormal inputs, as mode 3 does, and mode 2 flushes them, as mode 0 does.f32DenormalFlushFornow returns that input flush for the compares, and the existing paths do the rest: the sign-magnitude integer compare for kept denormals, and the flush before the compare otherwise. No driver denormal behaviour is involved.Source of semantics: measured with the hardware oracle's kernel template on gfx1030 (AMD Radeon RX 6800, AMD Windows driver 32.0.21045.5002 through its HIP runtime
amdhip64_6.dll):v_cmp) and EXEC (v_cmpx).The measured masks for modes 1 and 2 are the "kept" and "flushed" masks that
VCmpF32Denormalsalready pins for modes 3 and 0 (measured on gfx1036).A new entry in
docs/dev/debt/shader.mdrecords the measurement. The general "f32 denormals" entry, which says denormal modes 1 and 2 throw for the other instructions, is left unchanged because #5782 edits that line.Tested
Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe, on
main73efd940.agc_driver_vcmp_f32_denormal_modes(new) pins the measured results for the 16 x 16 operand pairs ofVCmpF32Denormals, forv_cmpandv_cmpxin denormal modes 1 and 2 at IEEE 0 and 1. It compiles 8 programs.mainit fails (mode 1 throws). With the change it passes in 0.1 s.agc_driver_vcmp_f32_denormals,agc_driver_f32_compare_constant,agc_driver_f32_denormal_flush,agc_driver_vopc_compare,agc_driver_vopc_compare_table,agc_driver_vopc_compare_f64andagc_driver_vop3_compare_modifierspass.anyps5-gpu-probes-v2-gfx1030.json.gz(probecmp_f32_denormal_modes).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
anyps5-gpu-probes-v2-gfx1030.json.gz
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:51Z.
Ran this on PR head
659eddb10(merge base73efd9407, 290 commits behind mainab9a47684).Setup: PR head checked out as-is (not rebased), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), Linux, ANYPS5_NO_SHADER_CACHE=1, GPU test run on lavapipe (Mesa 26.2.4 llvmpipe, LLVM 23.1.1).
So the test does reach modes 1 and 2. Without the change the recompiler refuses mode 1 outright, so this check does not show whether the asserted values would catch a wrong translation. The expected values come from the PR's RDNA2 measurements; llvmpipe does not confirm hardware behaviour.
Overlap: #6009, #6010 and #5782 edit the same switch in f32DenormalFlushFor, and #5941 edits the same function just after it. git merge-tree of this PR with #6009 is clean, so this may only need a re-check, not a rebase.
Not checked: other GPUs, Windows, or any title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:08Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
docs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Translation/src/VectorInstructions.cppdocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:55:18Z.
Measured
v_cmp_X_f32andv_cmpx_X_f32on our RDNA2 oracle (gfx1035) over 576 operand pairs (the test's 16 values plus 8 more denormal, minimum-normal, largest-finite and NaN edges), all 12 conditions, IEEE 0/1 and f32 denormal modes 0-3: inputs are flushed exactly when bit 0 of the field is clear, and the test's tables match the hardware bit for bit. Build, the agc tests on RADV and lavapipe, and the negative check (the new test fails without the change) are green; merging.