[llvm] [APFloat] Fix `IEEEFloat::addOrSubtractSignificand` and `IEEEFloat::normalize` (PR #98721)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 20 06:52:12 PDT 2024


================
@@ -560,6 +560,17 @@ TEST(APFloatTest, FMA) {
     EXPECT_EQ(-8.85242279E-41f, f1.convertToFloat());
   }
 
+  // Regression test for failing the `assert(!carry)` in
+  // `addOrSubtractSignificand` and normalizing the exponent even when the
+  // significand is zero if there is a lost fraction.
+  {
+    APFloat f1(-1.4728589E-38f);
----------------
beetrees wrote:

I've added some more tests and explicitly stated which case each test hits. It would be ideal to have some tests that directly test `addOrSubtractSignificand`, but as the method is private it isn't accessible from the unit tests.

https://github.com/llvm/llvm-project/pull/98721


More information about the llvm-commits mailing list