[SCEV] Check `Pred` first in isKnownPredicateViaSplitting
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 8 Oct 2015 03:46:00 +0000 (03:46 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 8 Oct 2015 03:46:00 +0000 (03:46 +0000)
Comparing `Pred` with `ICmpInst::ICMP_ULT` is cheaper that memory access
-- do that check before loading / storing `ProvingSplitPredicate`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249654 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index fbf6985916cc53fff78bd28b42c5982df4ccf198..05c1c6980cb383a13aea994b63f21ae8a77e16f3 100644 (file)
@@ -7132,7 +7132,7 @@ ScalarEvolution::isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
 bool ScalarEvolution::isKnownPredicateViaSplitting(ICmpInst::Predicate Pred,
                                                    const SCEV *LHS,
                                                    const SCEV *RHS) {
-  if (ProvingSplitPredicate)
+  if (Pred != ICmpInst::ICMP_ULT || ProvingSplitPredicate)
     return false;
 
   // Allowing arbitrary number of activations of isKnownPredicateViaSplitting on
@@ -7146,7 +7146,7 @@ bool ScalarEvolution::isKnownPredicateViaSplitting(ICmpInst::Predicate Pred,
   // expensive; and using isKnownNonNegative(RHS) is sufficient for most of the
   // interesting cases seen in practice.  We can consider "upgrading" L >= 0 to
   // use isKnownPredicate later if needed.
-  if (Pred == ICmpInst::ICMP_ULT && isKnownNonNegative(RHS) &&
+  if (isKnownNonNegative(RHS) &&
       isKnownPredicate(CmpInst::ICMP_SGE, LHS, getZero(LHS->getType())) &&
       isKnownPredicate(CmpInst::ICMP_SLT, LHS, RHS))
     return true;