Make IP Constant prop more aggressive about handling self recursive calls.
authorChris Lattner <sabre@nondot.org>
Wed, 10 Nov 2004 19:43:59 +0000 (19:43 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 10 Nov 2004 19:43:59 +0000 (19:43 +0000)
This implements IPConstantProp/recursion.ll

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

lib/Transforms/IPO/IPConstantPropagation.cpp

index a1e09e6beffe98945647d1fb727638454147e342..479f8e73ccb482c062bdafe89b0540786f2467f5 100644 (file)
@@ -81,7 +81,9 @@ bool IPCP::processFunction(Function &F) {
       
       // Check out all of the potentially constant arguments
       CallSite::arg_iterator AI = CS.arg_begin();
-      for (unsigned i = 0, e = ArgumentConstants.size(); i != e; ++i, ++AI) {
+      Function::aiterator Arg = F.abegin();
+      for (unsigned i = 0, e = ArgumentConstants.size(); i != e;
+           ++i, ++AI, ++Arg) {
         if (*AI == &F) return false;  // Passes the function into itself
 
         if (!ArgumentConstants[i].second) {
@@ -94,7 +96,7 @@ bool IPCP::processFunction(Function &F) {
               ++NumNonconstant;
               if (NumNonconstant == ArgumentConstants.size()) return false;
             }
-          } else {
+          } else if (*AI != &*Arg) {    // Ignore recursive calls with same arg
             // This is not a constant argument.  Mark the argument as
             // non-constant.
             ArgumentConstants[i].second = true;