[llvm] [APFloat] Fix `IEEEFloat::addOrSubtractSignificand` and `IEEEFloat::normalize` (PR #98721)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 07:21:31 PDT 2024
================
@@ -7440,4 +7515,79 @@ TEST(APFloatTest, Float4E2M1FNToFloat) {
EXPECT_TRUE(SmallestDenorm.isDenormal());
EXPECT_EQ(0x0.8p0, SmallestDenorm.convertToFloat());
}
+
+TEST(APFloatTest, AddOrSubtractSignificand) {
+ class TestIEEEFloat : detail::IEEEFloat {
+ TestIEEEFloat(bool sign, ExponentType exponent, integerPart significand)
+ : detail::IEEEFloat(1.0) {
+ // `addOrSubtractSignificand` only uses the sign, exponent and significand
+ this->sign = sign;
+ this->exponent = exponent;
+ this->significand.part = significand;
----------------
beetrees wrote:
The fields and `addOrSubtractSignificand` are protected so the only way to access them is via a subclass. Unfortunately just constructing a value via the public constructors is not sufficient as non-normalized significands are required to hit all the edge cases in `addOrSubtractSignificand`.
https://github.com/llvm/llvm-project/pull/98721
More information about the llvm-commits
mailing list