[llvm] 5097143 - [SCEV][NFC] Move check up the stack

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 08:09:30 PDT 2021


Author: Max Kazantsev
Date: 2021-03-16T22:09:17+07:00
New Revision: 5097143f0e7124d73646daa5de5d205579b9f7d2

URL: https://github.com/llvm/llvm-project/commit/5097143f0e7124d73646daa5de5d205579b9f7d2
DIFF: https://github.com/llvm/llvm-project/commit/5097143f0e7124d73646daa5de5d205579b9f7d2.diff

LOG: [SCEV][NFC] Move check up the stack

One of (and primary) callers of isBasicBlockEntryGuardedByCond is
isKnownPredicateAt, which makes isKnownPredicate check before it.
It already makes non-recursive check inside. So, on this execution
path this check is made twice. The only other caller is
isLoopEntryGuardedByCond. Moving the check there should save some
compile time.

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c94aca576282..ddb56562799e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9991,9 +9991,6 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
     assert(!verifyFunction(*BB->getParent(), &dbgs()) &&
            "This cannot be done on broken IR!");
 
-  if (isKnownViaNonRecursiveReasoning(Pred, LHS, RHS))
-    return true;
-
   // If we cannot prove strict comparison (e.g. a > b), maybe we can prove
   // the facts (a >= b && a != b) separately. A typical situation is when the
   // non-strict comparison is known from ranges and non-equality is known from
@@ -10102,6 +10099,10 @@ bool ScalarEvolution::isLoopEntryGuardedByCond(const Loop *L,
          "LHS is not available at Loop Entry");
   assert(isAvailableAtLoopEntry(RHS, L) &&
          "RHS is not available at Loop Entry");
+
+  if (isKnownViaNonRecursiveReasoning(Pred, LHS, RHS))
+    return true;
+
   return isBasicBlockEntryGuardedByCond(L->getHeader(), Pred, LHS, RHS);
 }
 


        


More information about the llvm-commits mailing list