[llvm] [ValueTracking] Compute knownbits from known fp classes (PR #86409)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 01:36:50 PDT 2024
================
@@ -1111,6 +1111,60 @@ 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)) {
+ Known.Zero.setAllBits();
+ Known.One.setAllBits();
+
+ if (FPClasses & fcSNan) {
+ APInt Payload = APInt::getAllOnes(FPType->getScalarSizeInBits());
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APFloat::getSNaN(FPType->getFltSemantics()).bitcastToAPInt()));
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APFloat::getSNaN(FPType->getFltSemantics(), &Payload)
+ .bitcastToAPInt()));
+ }
+
+ if (FPClasses & fcQNan) {
+ APInt Payload = APInt::getAllOnes(FPType->getScalarSizeInBits());
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APFloat::getQNaN(FPType->getFltSemantics()).bitcastToAPInt()));
+ Known = Known.intersectWith(KnownBits::makeConstant(
+ APFloat::getQNaN(FPType->getFltSemantics(), &Payload)
+ .bitcastToAPInt()));
+ }
----------------
dtcxzyw wrote:
Done. This approach didn't work (see https://github.com/llvm/llvm-project/pull/86409/commits/57b3d5ed9fea40f8baa23af6ab457e8f5d7f537d), so I removed them.
https://github.com/llvm/llvm-project/pull/86409
More information about the llvm-commits
mailing list