[llvm] ValueTracking: Identify implied fp classes by general fcmp (PR #66505)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 05:13:03 PST 2024
================
@@ -4245,6 +4245,139 @@ llvm::fcmpToClassTest(FCmpInst::Predicate Pred, const Function &F, Value *LHS,
return {Src, Mask};
}
+std::tuple<Value *, FPClassTest, FPClassTest>
+llvm::fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS,
+ const APFloat *ConstRHS, bool LookThroughSrc) {
+ auto [Val, ClassMask] =
+ fcmpToClassTest(Pred, F, LHS, ConstRHS, LookThroughSrc);
+ if (Val)
+ return {Val, ClassMask, ~ClassMask};
+
+ FPClassTest RHSClass = ConstRHS->classify();
+ assert((RHSClass == fcPosNormal || RHSClass == fcNegNormal ||
+ RHSClass == fcPosSubnormal || RHSClass == fcNegSubnormal) &&
+ "should have been recognized as an exact class test");
+
+ const bool IsNegativeRHS = (RHSClass & fcNegative) == RHSClass;
+ const bool IsPositiveRHS = (RHSClass & fcPositive) == RHSClass;
----------------
arsenm wrote:
Not for a nan
https://github.com/llvm/llvm-project/pull/66505
More information about the llvm-commits
mailing list