[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
Joshua Cranmer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 13:50:57 PDT 2024
================
@@ -14674,6 +14676,31 @@ static bool TryEvaluateBuiltinNaN(const ASTContext &Context,
return true;
}
+// Checks that the value x is in the range (-1;-0.5], [0.5; 1)
+static bool isInFrexpResultRange(const llvm::APFloat &x) {
+ llvm::APFloat minusOne(x.getSemantics(), "-1.0");
+ llvm::APFloat minusHalf(x.getSemantics(), "-0.5");
+ llvm::APFloat half(x.getSemantics(), "0.5");
+ llvm::APFloat one(x.getSemantics(), "1.0");
+
+ return ((x.compare(minusOne) == llvm::APFloat::cmpGreaterThan &&
+ x.compare(minusHalf) != llvm::APFloat::cmpGreaterThan) ||
+ (x.compare(half) != llvm::APFloat::cmpLessThan &&
+ x.compare(one) == llvm::APFloat::cmpLessThan));
----------------
jcranmer-intel wrote:
You can simplify this by checking that the absolute value is in [0.5, 1)
https://github.com/llvm/llvm-project/pull/88978
More information about the llvm-commits
mailing list