[llvm] [KnownFPClass] Refine positive zero and NaN result classes for sqrt (PR #214987)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 9 06:30:23 PDT 2026
================
@@ -556,15 +556,22 @@ KnownFPClass KnownFPClass::sqrt(const KnownFPClass &KnownSrc,
if (KnownSrc.isKnownNever(fcSNan))
Known.knownNot(fcSNan);
- // Any negative value besides -0 returns a nan.
- if (KnownSrc.isKnownNeverNaN() && KnownSrc.cannotBeOrderedLessThanZero())
+ // Any value < -0.0 returns NaN. However, a negative subnormal may be treated
+ // as zero depending on the input denormal mode.
+ if (KnownSrc.isKnownNever(fcNan | fcNegInf | fcNegNormal) &&
+ (KnownSrc.isKnownNever(fcNegSubnormal) || Mode.inputsAreZero()))
----------------
arsenm wrote:
This is a stronger use of the denormal mode than anywhere else here. Generally it's treated as a hazard; the value may be treated as 0 not that it must be. I think the langref rules assert that input flushing must definitely flush (compared to the lax output), but it's a fuzzy edge case. I'd prefer to take that conceptual leap separately
https://github.com/llvm/llvm-project/pull/214987
More information about the llvm-commits
mailing list