[llvm] ValueTracking: Identify implied fp classes by general fcmp (PR #66505)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 03:42:12 PST 2023


================
@@ -4269,18 +4402,21 @@ static FPClassTest computeKnownFPClassFromAssumes(const Value *V,
     Value *LHS, *RHS;
     uint64_t ClassVal = 0;
     if (match(I->getArgOperand(0), m_FCmp(Pred, m_Value(LHS), m_Value(RHS)))) {
-      auto [TestedValue, TestedMask] =
-          fcmpToClassTest(Pred, *F, LHS, RHS, true);
-      // First see if we can fold in fabs/fneg into the test.
-      if (TestedValue == V)
-        KnownFromAssume &= TestedMask;
-      else {
-        // Try again without the lookthrough if we found a different source
-        // value.
-        auto [TestedValue, TestedMask] =
-            fcmpToClassTest(Pred, *F, LHS, RHS, false);
-        if (TestedValue == V)
-          KnownFromAssume &= TestedMask;
+      const APFloat *CRHS;
+      if (match(RHS, m_APFloat(CRHS))) {
+        // First see if we can fold in fabs/fneg into the test.
+        auto [CmpVal, MaskIfTrue, MaskIfFalse] =
+            fcmpImpliesClass(Pred, *F, LHS, CRHS, true);
----------------
jayfoad wrote:

Could you make just one call to `fcmpImpliesClass`, passing in `LHS != V` for the `LookThroughSrc` argument?

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


More information about the llvm-commits mailing list