[llvm] [llvm] `APFloat`: Query `hasNanOrInf` from semantics (PR #116158)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 21:00:49 PST 2024


================
@@ -1127,19 +1129,11 @@ class APFloat : public APFloatBase {
   /// \param Semantics - type float semantics
   static APFloat getAllOnesValue(const fltSemantics &Semantics);
 
-  /// Returns true if the given semantics supports either NaN or Infinity.
+  /// Returns true if the given semantics supports NaN or Infinity.
   ///
   /// \param Sem - type float semantics
   static bool hasNanOrInf(const fltSemantics &Sem) {
-    switch (SemanticsToEnum(Sem)) {
-    default:
-      return true;
-    // Below Semantics do not support {NaN or Inf}
-    case APFloat::S_Float6E3M2FN:
-    case APFloat::S_Float6E2M3FN:
-    case APFloat::S_Float4E2M1FN:
-      return false;
-    }
+    return semanticsHasNan(Sem) || semanticsHasInf(Sem);
----------------
kuhar wrote:

Do we have unit tests that cover this already?

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


More information about the llvm-commits mailing list