indvars cruft: don't replace phi nodes for no reason.
authorAndrew Trick <atrick@apple.com>
Mon, 18 May 2015 16:49:34 +0000 (16:49 +0000)
committerAndrew Trick <atrick@apple.com>
Mon, 18 May 2015 16:49:34 +0000 (16:49 +0000)
Don't replace a phi with an identical phi. This was done long ago to
"preserve" IVUsers analysis. The code has already called
SE->forgetValue(PN) so I see no purpose in creating a new value for
the phi.

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

lib/Transforms/Scalar/IndVarSimplify.cpp

index 2ba3109354b613241e3c61381db244e2f025e809..600589c904c49fffb165f9bbc559e2620fa149d4 100644 (file)
@@ -621,16 +621,6 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) {
           PN->eraseFromParent();
         }
       }
-
-      // If we were unable to completely replace the PHI node, clone the PHI and
-      // delete the original one. This purges the original phi.
-      if (!LCSSASafePhiForRAUW) {
-        PHINode *NewPN = cast<PHINode>(PN->clone());
-        NewPN->takeName(PN);
-        NewPN->insertBefore(PN);
-        PN->replaceAllUsesWith(NewPN);
-        PN->eraseFromParent();
-      }
     }
   }