[llvm] [KnownFPClass] Correct denormal mode handling for `KnownFPClass::minMaxLike` (PR #220148)

Eric Ross via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 10:03:18 PDT 2026


================
@@ -172,6 +159,19 @@ KnownFPClass KnownFPClass::minMaxLike(const KnownFPClass &LHS_,
     }
   }
 
+  // Fixup zero handling if denormal outputs/inputs could be treated as zero.
+  //
+  // As there's no spec for denormal flushing, be conservative with the
+  // treatment of denormals that could be flushed to zero. For older
+  // subtargets on AMDGPU the min/max instructions would not flush the
+  // output and return the original value.
+  //
+  if (Mode != DenormalMode::getIEEE() && (!KnownLHS.isKnownNeverSubnormal() ||
+                                          !KnownRHS.isKnownNeverSubnormal())) {
+    Known.setKnownFPClasses(Known.getKnownFPClasses() | fcZero);
+    Known.setSignBit(std::nullopt);
----------------
ZERICO2005 wrote:

I agree. The function logic is too hard to follow at the moment, and I think it would be best to fix incorrectly inferring the sign bit after `minMaxLike` is split into multiple functions.


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


More information about the llvm-commits mailing list