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

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 02:49:07 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;
-    }
----------------
durga4github wrote:

I believe, it is meant for "not FiniteOnly".

Renaming the API as hasFiniteOnly and then inverting the conditions in APFloatTest.cpp would be cleaner.
What do you think?



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


More information about the llvm-commits mailing list