[llvm] Fix bitcasting E8M0 APFloat to APInt (PR #113298)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 09:44:56 PDT 2024


================
@@ -7614,6 +7614,15 @@ TEST(APFloatTest, ConvertDoubleToE8M0FNU) {
   EXPECT_EQ(status, APFloat::opUnderflow | APFloat::opInexact);
 }
 
+TEST(APFloatTest, Float8E8M0FNUBitcastToAPInt) {
+  // Regression test for verifying the low bit of the exponent when bitcasting
+  // to integer (zero mantissa).
+  APFloat f0(APFloat::Float8E8M0FNU(), "0.5");
+  APFloat f1(APFloat::Float8E8M0FNU(), "1.0");
+  EXPECT_EQ(f0.bitcastToAPInt(), 126) << f0;
+  EXPECT_EQ(f1.bitcastToAPInt(), 127) << f1;
+}
+
----------------
durga4github wrote:

Instead of a separate test for this, can actually add the bitcastToAPInt() for all 256 values in
E8M0FNUExhaustive test case?

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


More information about the llvm-commits mailing list