aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2025-04-14 14:30:00 +0800
committerGitHub <noreply@github.com>2025-04-14 14:30:00 +0800
commite710a5a9f274162c63e32aa8d88f6a734759b4a5 (patch)
tree4d55195b43e82d605c388740ec6836bb7de9bd74 /llvm/lib/Support/APFloat.cpp
parentffd5b148941a1146378a247c70c4faface3a1f96 (diff)
downloadllvm-e710a5a9f274162c63e32aa8d88f6a734759b4a5.zip
llvm-e710a5a9f274162c63e32aa8d88f6a734759b4a5.tar.gz
llvm-e710a5a9f274162c63e32aa8d88f6a734759b4a5.tar.bz2
[InstCombine] Fold fneg/fabs patterns with ppc_f128 (#130557)
This patch is needed by https://github.com/llvm/llvm-project/pull/130496.
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r--llvm/lib/Support/APFloat.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index e058010..a7b9f25 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -125,6 +125,9 @@ struct fltSemantics {
/* Whether this semantics can represent signed values */
bool hasSignedRepr = true;
+
+ /* Whether the sign bit of this semantics is the most significant bit */
+ bool hasSignBitInMSB = true;
};
static constexpr fltSemantics semIEEEhalf = {15, -14, 11, 16};
@@ -144,9 +147,15 @@ static constexpr fltSemantics semFloat8E4M3B11FNUZ = {
4, -10, 4, 8, fltNonfiniteBehavior::NanOnly, fltNanEncoding::NegativeZero};
static constexpr fltSemantics semFloat8E3M4 = {3, -2, 5, 8};
static constexpr fltSemantics semFloatTF32 = {127, -126, 11, 19};
-static constexpr fltSemantics semFloat8E8M0FNU = {
- 127, -127, 1, 8, fltNonfiniteBehavior::NanOnly, fltNanEncoding::AllOnes,
- false, false};
+static constexpr fltSemantics semFloat8E8M0FNU = {127,
+ -127,
+ 1,
+ 8,
+ fltNonfiniteBehavior::NanOnly,
+ fltNanEncoding::AllOnes,
+ false,
+ false,
+ false};
static constexpr fltSemantics semFloat6E3M2FN = {
4, -2, 3, 6, fltNonfiniteBehavior::FiniteOnly};
@@ -358,6 +367,10 @@ bool APFloatBase::isIEEELikeFP(const fltSemantics &semantics) {
return SemanticsToEnum(semantics) <= S_IEEEquad;
}
+bool APFloatBase::hasSignBitInMSB(const fltSemantics &semantics) {
+ return semantics.hasSignBitInMSB;
+}
+
bool APFloatBase::isRepresentableAsNormalIn(const fltSemantics &Src,
const fltSemantics &Dst) {
// Exponent range must be larger.