File tree 2 files changed +10
-1
lines changed
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 {
3663
3663
std::array<uint64_t , (S.sizeInBits + 63 ) / 64 > words;
3664
3664
auto words_iter =
3665
3665
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 ) {
3667
3667
// Clear the integer bit.
3668
3668
words[mysignificand.size () - 1 ] &= significand_mask;
3669
3669
}
Original file line number Diff line number Diff line change @@ -7614,6 +7614,15 @@ TEST(APFloatTest, ConvertDoubleToE8M0FNU) {
7614
7614
EXPECT_EQ(status, APFloat::opUnderflow | APFloat::opInexact);
7615
7615
}
7616
7616
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
+
7617
7626
TEST(APFloatTest, Float6E3M2FNFromString) {
7618
7627
// Exactly representable
7619
7628
EXPECT_EQ(28, APFloat(APFloat::Float6E3M2FN(), "28").convertToDouble());
You can’t perform that action at this time.
0 commit comments