[llvm-bugs] [Bug 44007] New: assertion failure in APFloat.fusedMultiplyAdd with subnormal arguments

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 19 00:26:32 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44007

            Bug ID: 44007
           Summary: assertion failure in APFloat.fusedMultiplyAdd with
                    subnormal arguments
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: RESOLVED
          Severity: enhancement
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: jay.foad at gmail.com
                CC: ehudkatz at gmail.com, llvm-bugs at lists.llvm.org
                CC: ehudkatz at gmail.com
        Resolution: DUPLICATE
            Status: RESOLVED

If I add this unit test:

diff --git a/llvm/unittests/ADT/APFloatTest.cpp
b/llvm/unittests/ADT/APFloatTest.cpp
index c76347ed056..a6398bbb684 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -530,6 +530,15 @@ TEST(APFloatTest, FMA) {
     EXPECT_FALSE(losesInfo);
     EXPECT_EQ(4.0f, M1.convertToFloat());
   }
+
+  // Regression test that failed an assertion.
+  {
+    APFloat f1(-8.85242279E-41f);
+    APFloat f2(2.0f);
+    APFloat f3(8.85242279E-41f);
+    f1.fusedMultiplyAdd(f2, f3, APFloat::rmNearestTiesToEven);
+    EXPECT_EQ(-8.85242279E-41f, f1.convertToFloat());
+  }
 }

 TEST(APFloatTest, MinNum) {

then it fails with an assertion failure:

ADTTests: /home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp:1521:
llvm::lostFraction llvm::detail::IEEEFloat::addOrSubtractSignificand(const
llvm::detail::IEEEFloat &, bool): Assertion `!carry' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6890801 in __GI_abort () at abort.c:79
#2  0x00007ffff688039a in __assert_fail_base (fmt=0x7ffff6a077d8 "%s%s%s:%u:
%s%sAssertion `%s' failed.\n%n", assertion=assertion at entry=0x20a334 "!carry",
file=file at entry=0x2280bf
"/home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp",
line=line at entry=1521, 
    function=function at entry=0x27527b "llvm::lostFraction
llvm::detail::IEEEFloat::addOrSubtractSignificand(const llvm::detail::IEEEFloat
&, bool)") at assert.c:92
#3  0x00007ffff6880412 in __GI___assert_fail (assertion=0x20a334 "!carry",
file=0x2280bf "/home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp",
line=1521, 
    function=0x27527b "llvm::lostFraction
llvm::detail::IEEEFloat::addOrSubtractSignificand(const llvm::detail::IEEEFloat
&, bool)") at assert.c:101
#4  0x00000000009499a6 in llvm::detail::IEEEFloat::addOrSubtractSignificand
(this=0x7fffffffd3d0, rhs=..., subtract=true) at
/home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp:1521
#5  0x000000000094918e in llvm::detail::IEEEFloat::multiplySignificand
(this=0x7fffffffd3d0, rhs=..., addend=0x7fffffffd390) at
/home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp:1066
#6  0x000000000094b726 in llvm::detail::IEEEFloat::fusedMultiplyAdd
(this=0x7fffffffd3d0, multiplicand=..., addend=...,
rounding_mode=llvm::APFloatBase::rmNearestTiesToEven) at
/home/jayfoad2/git/llvm-project/llvm/lib/Support/APFloat.cpp:1818
#7  0x00000000004bc29a in llvm::APFloat::fusedMultiplyAdd (this=0x7fffffffd3c8,
Multiplicand=..., Addend=..., RM=llvm::APFloatBase::rmNearestTiesToEven) at
/home/jayfoad2/git/llvm-project/llvm/include/llvm/ADT/APFloat.h:1017
#8  0x0000000000454202 in (anonymous namespace)::APFloatTest_FMA_Test::TestBody
(this=0xb14b00) at
/home/jayfoad2/git/llvm-project/llvm/unittests/ADT/APFloatTest.cpp:539
#9  0x0000000000a300be in
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>
(object=0xb14b00, method=&virtual testing::Test::TestBody(), location=0x294442
"the test body") at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2402
#10 0x0000000000a1ef62 in
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>
(object=0xb14b00, method=&virtual testing::Test::TestBody(), location=0x294442
"the test body") at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2455
#11 0x0000000000a0cd76 in testing::Test::Run (this=0xb14b00) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474
#12 0x0000000000a0d633 in testing::TestInfo::Run (this=0xa95eb0) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656
#13 0x0000000000a0db8c in testing::TestCase::Run (this=0xa95bd0) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774
#14 0x0000000000a132d1 in testing::internal::UnitTestImpl::RunAllTests
(this=0xa95140) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649
#15 0x0000000000a32c5e in
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool> (object=0xa95140, 
    method=(bool
(testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const))
0xa12ff0 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x21ebee
"auxiliary test code (environments or event listeners)")
    at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2402
#16 0x0000000000a208c2 in
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool> (object=0xa95140, 
    method=(bool
(testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const))
0xa12ff0 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x21ebee
"auxiliary test code (environments or event listeners)")
    at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2455
#17 0x0000000000a12fc2 in testing::UnitTest::Run (this=0xa82bc0
<testing::UnitTest::GetInstance()::instance>) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257
#18 0x0000000000a05451 in RUN_ALL_TESTS () at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233
#19 0x0000000000a053e7 in main (argc=1, argv=0x7fffffffde48) at
/home/jayfoad2/git/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50

I suspect that IEEEFloat::addOrSubtractSignificand is making some assumptions
about subnormal values, that fusedMultiplyAdd is not respecting.

--- Comment #1 from Ehud Katz <ehudkatz at gmail.com> ---


*** This bug has been marked as a duplicate of bug 44010 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191119/709943f4/attachment-0001.html>


More information about the llvm-bugs mailing list