[PATCH] D139316: ValueTracking: Teach isKnownNeverInfinity about rounding intrinsics

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 11:10:30 PST 2022


sepavloff added a comment.

In D139316#3995455 <https://reviews.llvm.org/D139316#3995455>, @arsenm wrote:

> Special case ppcfp128. Not sure if we need to exclude bfloat16 since it's exponent bits is larger than mantissa

`bfloat16` has the same exponent range as `float`, that is from -126 to 127. If number of mantissa bit were larger than 127, there would be problems. Actually large `bfloat16` values are integers.



================
Comment at: llvm/include/llvm/IR/Type.h:189-194
+  /// Returns true if this floating-point type with APFloat::IEEEFloat
+  /// representation (i.e. not ppc_fp128).
+  bool isIEEEFloatRepresentationTy() const {
+    return isIEEELikeFPTy() || getTypeID() == X86_FP80TyID;
+  }
+
----------------
What you need for this patch is availability of fixed size mantissa. Custom short FP types, like 8 and 16 bit floats may be non-IEEE in strict sense but they still provide definite number of mantissa bits.

I would propose to use `isPPC_FP128Ty` to filter out indeterminate precision formats  or, if you want, to define a predicate like:
```
/// Returns true if this floating-point type represents unevaluated sum of shorter floating-point values.
bool isMultiWordFPType() const {
    return getTypeID() == PPC_FP128TyID;
}
```
If someone uses additional types with such property in their LLVM-based compilers, they can extend this function.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139316/new/

https://reviews.llvm.org/D139316



More information about the llvm-commits mailing list