[llvm] [KnownFPClass] Add output/input denormal helpers (PR #225575)

Tim Gymnich via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 02:25:25 PDT 2026


================
@@ -850,31 +870,19 @@ KnownFPClass KnownFPClass::atan2(const KnownFPClass &KnownY,
 
   Known.propagateNonNaN(KnownY, KnownX);
 
-  // Negative subnormals could be treated like positive zero.
-  const bool XCannotHavePositiveInput = KnownX.isKnownNever(fcPositive) &&
-                                        KnownX.isKnownNeverLogicalPosZero(Mode);
-  const bool YCannotHavePositiveInput = KnownY.isKnownNever(fcPositive) &&
-                                        KnownY.isKnownNeverLogicalPosZero(Mode);
-
   // If x <= -0.0, then |atan2(y, x)| >= pi/2
-  if (XCannotHavePositiveInput)
+  if (KnownX.isKnownNever(fcPositive))
     Known.knownNot(fcZero | fcSubnormal);
 
   // If y >= +0.0, then atan2(y, x) >= +0.0
   if (KnownY.isKnownNever(fcNegative))
     Known.knownNot(fcNegative);
 
   // If y <= -0.0, then atan2(y, x) <= -0.0
-  // We do this deduction last in case we were able to rule out a negative
-  // subnormal result earlier.
-  if (YCannotHavePositiveInput) {
-    Known.knownNot(fcPosSubnormal | fcPosNormal | fcPosInf);
-    // Negative subnormal results can flush to +0.0.
-    if (Known.isKnownNever(fcNegSubnormal) || !Mode.outputsMayBePositiveZero())
-      Known.knownNot(fcPosZero);
-  }
+  if (KnownY.isKnownNever(fcPositive))
+    Known.knownNot(fcPositive);
 
-  return Known;
+  return applyOutputDenormalMode(Known, Mode);
----------------
tgymnich wrote:

`Known.knownNot(fcPositive);` may set negative sign, while `applyOutputDenormalMode` may add `fcPosZero` again without setting sign back to unknown.

https://github.com/llvm/llvm-project/pull/225575


More information about the llvm-commits mailing list