[llvm] Reland "[ValueTracking] Compute knownbits from known fp classes" (PR #92084)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 01:58:55 PDT 2024
================
@@ -1118,6 +1118,42 @@ static void computeKnownBitsFromOperator(const Operator *I,
break;
}
+ const Value *V;
+ // Handle bitcast from floating point to integer.
+ if (match(I, m_ElementWiseBitCast(m_Value(V))) &&
+ V->getType()->isFPOrFPVectorTy()) {
+ Type *FPType = V->getType()->getScalarType();
+ KnownFPClass Result = computeKnownFPClass(V, fcAllFlags, Depth + 1, Q);
+ FPClassTest FPClasses = Result.KnownFPClasses;
+
+ if (Result.isKnownNever(fcNormal | fcSubnormal | fcNan)) {
+ Known.Zero.setAllBits();
+ Known.One.setAllBits();
+
+ if (FPClasses & fcInf)
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APFloat::getInf(FPType->getFltSemantics()).bitcastToAPInt()));
+
+ if (FPClasses & fcZero)
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APInt::getZero(FPType->getScalarSizeInBits())));
+
+ Known.Zero.clearSignBit();
+ Known.One.clearSignBit();
+ }
+
+ if (Result.SignBit) {
+ if (*Result.SignBit)
+ Known.makeNegative();
+ else
+ Known.makeNonNegative();
+ }
+
+ assert(!Known.hasConflict() && "Bits known to be one AND zero?");
+
----------------
arsenm wrote:
Delete blank this blank line
https://github.com/llvm/llvm-project/pull/92084
More information about the llvm-commits
mailing list