perf(shader): drop flushes of f32 results that cannot be denormal #5086
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5086"
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 ErenYeager1836 on 2026-10-13T11:11:35Z.
What
DenormalFlushEliminatorremoves the f32 denormal flush (and,iequal,and,select, 4 IR instructions) on values it can prove are not denormal. Narrowed to avoid overlap with #4490, #4737, and #4539:FPTrunc32,FPRoundEven32: the result is integral, ±0, ±inf or NaN.FPSqrt,FPRecipSqrt32: the square root of the smallest denormal is ~2^-74.5, and the reciprocal square root of the largest float is ~2^-64, so neither produces an f32 denormal.BitwiseAnd32with0x80000000(always ±0), andBitwiseOr32with a constant that has an exponent bit set (the exponent stays non-zero). This covers the sign and signed-infinity arms thatunaryFloatSpecialsbuilds, allowing flushes afterv_sqrt_f32,v_rsq_f32andv_floor_f32to be eliminated.core/libs/prx/libSceAgcDriver/tests/DenormalFlushElimination.cpp.Carried from @Friesmaniac with attribution preserved.
Tested
Linux and Windows:
core/libs/prx/libSceAgcDriver/tests/DenormalFlushElimination.cpptest suite passes.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)Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-13T15:56:35Z.
@ErenYeager1836, this overlaps three open PRs that change the same switch in
DenormalFreeValues:FPMin32,FPMax32,FPMinTri32,FPMaxTri32andFPMedTri32when every operand is denormal-free, plusFPFloor32andFPCeil32, with tests inDenormalFlushElimination.cpp.FPFract32,FPSinandFPCos. The first new test here expects the flush afterFPFract32to stay, so it fails once #4737 is in.EmitFlushF32DenormToSignedZero, which is the reason given here forFPSqrtandFPRecipSqrt32. Both rules still hold without it: the square root of the smallest denormal is about 2^-74.5, and the reciprocal square root of the largest float is about 2^-64. Only the description's reason would change.FPMul32case to the same switch.What's new here is
FPTrunc32,FPRoundEven32,FPSqrt,FPRecipSqrt32and theBitwiseAnd32/BitwiseOr32masks. Could you narrow this PR to those and list #4490 under Depends on? Then the two won't conflict. If this one lands first, I'll rebase #4737 onto it.Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-13T16:04:59Z.
Thanks for the thorough breakdown @karanvora2599!
I have rebased onto current
mainand narrowed this PR specifically to the non-overlapping operations:FPTrunc32,FPRoundEven32,FPSqrt,FPRecipSqrt32, and the bitwise mask handling (BitwiseAnd32with0x80000000andBitwiseOr32setting exponent bits).FPFloor32/FPCeil32that are covered by #4490, as well as the test asserting onFPFract32to avoid conflicts with #4737.Depends on: #4490.Imported from boykopovar/AnyPS5. Originally posted by karanvora2599 on 2026-10-13T21:53:53Z.
Thanks @ErenYeager1836. I checked the narrowed diff and each new rule holds:
FPSqrtis f32-only (FPSqrt64is a separate opcode).0x80000000gives ±0.It no longer overlaps #4490 or #4737 beyond neighbouring lines.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:33:43Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed