[llvm-commits] [llvm] r53691 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Wed Jul 16 10:52:31 PDT 2008


Author: resistor
Date: Wed Jul 16 12:52:31 2008
New Revision: 53691

URL: http://llvm.org/viewvc/llvm-project?rev=53691&view=rev
Log:
There's no need to iterate block merging and PRE.  In fact, iterating the latter
could cause problems for memdep when it breaks critical edges.

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=53691&r1=53690&r2=53691&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Jul 16 12:52:31 2008
@@ -727,7 +727,6 @@
       
       AU.addPreserved<DominatorTree>();
       AU.addPreserved<AliasAnalysis>();
-      AU.addPreserved<MemoryDependenceAnalysis>();
     }
   
     // Helper fuctions
@@ -1121,11 +1120,22 @@
   bool changed = false;
   bool shouldContinue = true;
   
+  // Merge unconditional branches, allowing PRE to catch more
+  // optimization opportunities.
+  for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ) {
+    BasicBlock* BB = FI;
+    ++FI;
+    changed |= mergeBlockIntoPredecessor(BB);
+  }
+  
   while (shouldContinue) {
     shouldContinue = iterateOnFunction(F);
     changed |= shouldContinue;
   }
   
+  if (EnablePRE)
+    changed |= performPRE(F);
+  
   return changed;
 }
 
@@ -1382,15 +1392,6 @@
   VN.clear();
   phiMap.clear();
   
-  // Merge unconditional branches, allowing PRE to catch more
-  // optimization opportunities.
-  bool mergedBlocks = false;
-  for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ) {
-    BasicBlock* BB = FI;
-    ++FI;
-    mergedBlocks |= mergeBlockIntoPredecessor(BB);
-  }
-  
   for (DenseMap<BasicBlock*, ValueNumberScope*>::iterator
        I = localAvail.begin(), E = localAvail.end(); I != E; ++I)
     delete I->second;
@@ -1404,8 +1405,5 @@
        DE = df_end(DT.getRootNode()); DI != DE; ++DI)
     changed |= processBlock(*DI);
   
-  if (EnablePRE)
-    changed |= performPRE(F);
-  
-  return changed || mergedBlocks;
+  return changed;
 }





More information about the llvm-commits mailing list