[llvm] [ValueTracking] Compute knownbits from known fp classes (PR #86409)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 07:03:43 PDT 2024


================
@@ -1121,6 +1121,40 @@ static void computeKnownBitsFromOperator(const Operator *I,
       break;
     }
 
+    Value *V;
+    // Handle bitcast from floating point to integer.
+    if (match(const_cast<Operator *>(I), m_ElementWiseBitCast(m_Value(V))) &&
+        V->getType()->isFPOrFPVectorTy()) {
+      KnownFPClass Result = computeKnownFPClass(V, fcAllFlags, Depth + 1, Q);
+      if (Result.SignBit) {
+        if (*Result.SignBit)
+          Known.makeNegative();
+        else
+          Known.makeNonNegative();
+      }
+
+      Type *FPType = V->getType()->getScalarType();
+      if (FPType->isIEEELikeFPTy()) {
----------------
arsenm wrote:

For x86_fp80, you still know all the exponent bits are 1. The mantissa bits are more confusing, but you're only really using the mantissa bits here to get the number of exponent bits 

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


More information about the llvm-commits mailing list