File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3663,7 +3663,7 @@ APInt IEEEFloat::convertIEEEFloatToAPInt() const {
36633663 std::array<uint64_t , (S.sizeInBits + 63 ) / 64 > words;
36643664 auto words_iter =
36653665 std::copy_n (mysignificand.begin (), mysignificand.size (), words.begin ());
3666- if constexpr (significand_mask != 0 ) {
3666+ if constexpr (significand_mask != 0 || trailing_significand_bits == 0 ) {
36673667 // Clear the integer bit.
36683668 words[mysignificand.size () - 1 ] &= significand_mask;
36693669 }
Original file line number Diff line number Diff line change @@ -7614,6 +7614,15 @@ TEST(APFloatTest, ConvertDoubleToE8M0FNU) {
76147614 EXPECT_EQ (status, APFloat::opUnderflow | APFloat::opInexact);
76157615}
76167616
7617+ TEST (APFloatTest, Float8E8M0FNUBitcastToAPInt) {
7618+ // Regression test for verifying the low bit of the exponent when bitcasting
7619+ // to integer (zero mantissa).
7620+ APFloat f0 (APFloat::Float8E8M0FNU (), " 0.5" );
7621+ APFloat f1 (APFloat::Float8E8M0FNU (), " 1.0" );
7622+ EXPECT_EQ (f0.bitcastToAPInt (), 126 ) << f0;
7623+ EXPECT_EQ (f1.bitcastToAPInt (), 127 ) << f1;
7624+ }
7625+
76177626TEST (APFloatTest, Float6E3M2FNFromString) {
76187627 // Exactly representable
76197628 EXPECT_EQ (28 , APFloat (APFloat::Float6E3M2FN (), " 28" ).convertToDouble ());
You can’t perform that action at this time.
0 commit comments