[llvm] [APFloat] Add APFloat support for E8M0 type (PR #107127)
Durgadoss R via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 04:11:15 PDT 2024
================
@@ -1106,25 +1129,26 @@ bool IEEEFloat::isSignificandAllZerosExceptMSB() const {
return false;
}
- const unsigned NumHighBits =
- PartCount * integerPartWidth - semantics->precision + 1;
- return Parts[PartCount - 1] == integerPart(1)
- << (integerPartWidth - NumHighBits);
+ const unsigned NumHighBits = getNumHighBits();
+ const integerPart MSBMask = integerPart(1)
+ << (integerPartWidth - NumHighBits);
+ return ((semantics->precision <= 1) || (Parts[PartCount - 1] == MSBMask));
}
bool IEEEFloat::isLargest() const {
+ bool IsMaxExp = isFiniteNonZero() && exponent == semantics->maxExponent;
if (semantics->nonFiniteBehavior == fltNonfiniteBehavior::NanOnly &&
semantics->nanEncoding == fltNanEncoding::AllOnes) {
// The largest number by magnitude in our format will be the floating point
// number with maximum exponent and with significand that is all ones except
// the LSB.
- return isFiniteNonZero() && exponent == semantics->maxExponent &&
- isSignificandAllOnesExceptLSB();
+ return APFloat::hasSignificand(*semantics)
+ ? (IsMaxExp && isSignificandAllOnesExceptLSB())
+ : IsMaxExp;
----------------
durga4github wrote:
Yes, updated in the latest revision.
Resolving,
https://github.com/llvm/llvm-project/pull/107127
More information about the llvm-commits
mailing list