[llvm-branch-commits] [llvm-branch] r89300 - in /llvm/branches/Apple/Leela: include/llvm/Transforms/Utils/Local.h lib/Analysis/IVUsers.cpp lib/Transforms/Utils/LoopSimplify.cpp lib/Transforms/Utils/SimplifyCFG.cpp

Jim Grosbach grosbach at apple.com
Wed Nov 18 18:22:31 PST 2009


Author: grosbach
Date: Wed Nov 18 20:22:30 2009
New Revision: 89300

URL: http://llvm.org/viewvc/llvm-project?rev=89300&view=rev
Log:
merge 89297 89298 89299

Modified:
    llvm/branches/Apple/Leela/include/llvm/Transforms/Utils/Local.h
    llvm/branches/Apple/Leela/lib/Analysis/IVUsers.cpp
    llvm/branches/Apple/Leela/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/branches/Apple/Leela/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/branches/Apple/Leela/include/llvm/Transforms/Utils/Local.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/Transforms/Utils/Local.h?rev=89300&r1=89299&r2=89300&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/Transforms/Utils/Local.h Wed Nov 18 20:22:30 2009
@@ -86,6 +86,13 @@
 void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, Pass *P = 0);
     
   
+/// EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI
+/// nodes in this block. This doesn't try to be clever about PHI nodes
+/// which differ only in the order of the incoming values, but instcombine
+/// orders them so it usually won't matter.
+///
+bool EliminateDuplicatePHINodes(BasicBlock *BB);
+
 /// SimplifyCFG - This function is used to do simplification of a CFG.  For
 /// example, it adjusts branches to branches to eliminate the extra hop, it
 /// eliminates unreachable basic blocks, and does other "peephole" optimization

Modified: llvm/branches/Apple/Leela/lib/Analysis/IVUsers.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Analysis/IVUsers.cpp?rev=89300&r1=89299&r2=89300&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Analysis/IVUsers.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Analysis/IVUsers.cpp Wed Nov 18 20:22:30 2009
@@ -24,6 +24,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/CommandLine.h"
 #include <algorithm>
 using namespace llvm;
 
@@ -31,6 +32,10 @@
 static RegisterPass<IVUsers>
 X("iv-users", "Induction Variable Users", false, true);
 
+static cl::opt<bool>
+SimplifyIVUsers("simplify-iv-users", cl::Hidden, cl::init(false),
+          cl::desc("Restrict IV Users to loop-invariant strides"));
+
 Pass *llvm::createIVUsersPass() {
   return new IVUsers();
 }
@@ -208,6 +213,11 @@
   if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT))
     return false;  // Non-reducible symbolic expression, bail out.
 
+  // Keep things simple. Don't touch loop-variant strides.
+  if (SimplifyIVUsers && !Stride->isLoopInvariant(L)
+      && L->contains(I->getParent()))
+    return false;
+
   SmallPtrSet<Instruction *, 4> UniqueUsers;
   for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
        UI != E; ++UI) {

Modified: llvm/branches/Apple/Leela/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Utils/LoopSimplify.cpp?rev=89300&r1=89299&r2=89300&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Utils/LoopSimplify.cpp Wed Nov 18 20:22:30 2009
@@ -305,6 +305,12 @@
     }
   }
 
+  // If there are duplicate phi nodes (for example, from loop rotation),
+  // get rid of them.
+  for (Loop::block_iterator BB = L->block_begin(), E = L->block_end();
+       BB != E; ++BB)
+    EliminateDuplicatePHINodes(*BB);
+
   return Changed;
 }
 

Modified: llvm/branches/Apple/Leela/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Utils/SimplifyCFG.cpp?rev=89300&r1=89299&r2=89300&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Utils/SimplifyCFG.cpp Wed Nov 18 20:22:30 2009
@@ -1754,7 +1754,7 @@
 /// which differ only in the order of the incoming values, but instcombine
 /// orders them so it usually won't matter.
 ///
-static bool EliminateDuplicatePHINodes(BasicBlock *BB) {
+bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) {
   bool Changed = false;
   
   // This implementation doesn't currently consider undef operands





More information about the llvm-branch-commits mailing list