[llvm] [APFloat] Add APFloat support for E8M0 type (PR #107127)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 04:49:41 PDT 2024


================
@@ -1075,6 +1099,11 @@ bool IEEEFloat::isSignificandAllOnesExceptLSB() const {
 }
 
 bool IEEEFloat::isSignificandAllZeros() const {
+  // For the E8M0 format, this is always true since there are no
+  // actual significand bits.
+  if (semantics == &semFloat8E8M0FN)
+    return true;
----------------
durga4github wrote:

I also found it inelegant to special case this (and the AllOnes case below).

But the fact that this format does not have any precision needs to be handled, either here or in the NumHighBits calculation below. As far as I see, APFloat expects the precision to be at least 2 (at least 1 bit of actual precision + 1 integral bit for internal representation).

So, I think, instead of doing a special-case check on the semantics-type, it will be more consistent with the existing code to perform the condition checks on "semantics->precision".  Let me know if this sounds reasonable.

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


More information about the llvm-commits mailing list