[llvm] [ValueTracking] Compute knownbits from known fp classes (PR #86409)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 09:28:31 PDT 2024
================
@@ -1105,6 +1105,37 @@ 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();
+ int MantissaWidth = FPType->getFPMantissaWidth();
+ if (MantissaWidth != -1) {
+ if (Result.isKnownOnly(fcInf)) {
+ Known.Zero.setLowBits(MantissaWidth);
+ Known.One.setBits(MantissaWidth, BitWidth - 1);
----------------
goldsteinn wrote:
Maybe a better approach in general would be to intersect the `KnownBits(APFloat::<fpclass>().bitToAPInt())` for all the possible fpclasses.
https://github.com/llvm/llvm-project/pull/86409
More information about the llvm-commits
mailing list