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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 13 10:42:16 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()) {
----------------
dtcxzyw wrote:

It will cause assertion failure if we treat ppcf128 as not understandable. Some existing code calls `getFPMantissaWidth` unconditionally.

https://github.com/llvm/llvm-project/blob/61f1f1300254e91334404f0d22e75e96f0d98a85/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L7511-L7514

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


More information about the llvm-commits mailing list