[llvm] [llvm] `APFloat`: Query `hasNanOrInf` from semantics (PR #116158)
Matthias Springer via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 21:17:17 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);
----------------
matthias-springer wrote:
`hasNanOrInf` is used in `APFloatTest.cpp`. (The test is a bit suspicious though. It calls `APFloat::getInf` **and** `APFloat::getNaN` if `hasNanOrInf` returns "true".
https://github.com/llvm/llvm-project/pull/116158
More information about the llvm-commits
mailing list