[clang] [llvm] [LLVM][APFloat] Add APFloat support for 8-bit UE5M3 type (PR #210720)

Durgadoss R via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 05:46:55 PDT 2026


================
@@ -9860,6 +9898,298 @@ TEST(APFloatTest, ConvertDoubleToE8M0FNU) {
   EXPECT_EQ(status, APFloat::opUnderflow | APFloat::opInexact);
 }
 
+TEST(APFloatTest, Float8E5M3FNUValues) {
+  // High end of the range
+  auto test = APFloat(APFloat::Float8E5M3FNU(), "0x1.c0p16");
+  EXPECT_EQ(0x1.c0p16, test.convertToDouble());
+
+  test = APFloat(APFloat::Float8E5M3FNU(), "0x1.c0p15");
+  EXPECT_EQ(0x1.cp15, test.convertToDouble());
+
+  test = APFloat(APFloat::Float8E5M3FNU(), "0x1.0p14");
+  EXPECT_EQ(0x1.0p14, test.convertToDouble());
+
+  // tests the fix in makeLargest()
----------------
durga4github wrote:

This fix was specific to the `M0` type and nothing special for this `M3` format here.
Also, this is already getting tested in line 2321 above. So, we can remove this getLargest() test from here.

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


More information about the cfe-commits mailing list