[llvm] 0d96ea0 - [ValueTracking] Move matchSimpleRecurrence out of line

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 15:06:09 PST 2021


Author: Benjamin Kramer
Date: 2021-03-09T00:04:47+01:00
New Revision: 0d96ea0792bccca804ed89f7116ef518e40bf34a

URL: https://github.com/llvm/llvm-project/commit/0d96ea0792bccca804ed89f7116ef518e40bf34a
DIFF: https://github.com/llvm/llvm-project/commit/0d96ea0792bccca804ed89f7116ef518e40bf34a.diff

LOG: [ValueTracking] Move matchSimpleRecurrence out of line

The header only has a forward declaration of PHINode available, and this
function doesn't seem to get much out of inlining.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/ValueTracking.h
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 64e953282f2c..e2c5785f6b05 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -768,14 +768,8 @@ constexpr unsigned MaxAnalysisRecursionDepth = 6;
                              Value *&Start, Value *&Step);
 
   /// Analogous to the above, but starting from the binary operator
-  inline bool matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P,
-                                    Value *&Start, Value *&Step) {
-    BinaryOperator *BO = nullptr;
-    P = dyn_cast<PHINode>(I->getOperand(0));
-    if (!P)
-      P = dyn_cast<PHINode>(I->getOperand(1));
-    return P && matchSimpleRecurrence(P, BO, Start, Step) && BO == I;
-  }
+  bool matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P,
+                                    Value *&Start, Value *&Step);
 
   /// Return true if RHS is known to be implied true by LHS.  Return false if
   /// RHS is known to be implied false by LHS.  Otherwise, return None if no

diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 0a5071881414..79399cf058bd 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6102,6 +6102,15 @@ bool llvm::matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO,
   return false;
 }
 
+bool llvm::matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P,
+                                 Value *&Start, Value *&Step) {
+  BinaryOperator *BO = nullptr;
+  P = dyn_cast<PHINode>(I->getOperand(0));
+  if (!P)
+    P = dyn_cast<PHINode>(I->getOperand(1));
+  return P && matchSimpleRecurrence(P, BO, Start, Step) && BO == I;
+}
+
 /// Return true if "icmp Pred LHS RHS" is always true.
 static bool isTruePredicate(CmpInst::Predicate Pred, const Value *LHS,
                             const Value *RHS, const DataLayout &DL,


        


More information about the llvm-commits mailing list