[llvm-commits] [llvm] r45344 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Chris Lattner sabre at nondot.org
Mon Dec 24 11:32:58 PST 2007


Author: lattner
Date: Mon Dec 24 13:32:55 2007
New Revision: 45344

URL: http://llvm.org/viewvc/llvm-project?rev=45344&view=rev
Log:
add a -backedge-hack llc-beta option to codegenprepare.
When specified, don't split backedges of single-bb loops.
This helps address PR1877


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

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

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Mon Dec 24 13:32:55 2007
@@ -37,6 +37,8 @@
 namespace {
   cl::opt<bool> OptExtUses("optimize-ext-uses",
                            cl::init(true), cl::Hidden);
+  // LLCBETA option.
+  cl::opt<bool> DontHackBackedge("backedge-hack", cl::Hidden);
 }
 
 namespace {  
@@ -264,7 +266,7 @@
 }
 
 
-/// SplitEdgeNicely - Split the critical edge from TI to it's specified
+/// SplitEdgeNicely - Split the critical edge from TI to its specified
 /// successor if it will improve codegen.  We only do this if the successor has
 /// phi nodes (otherwise critical edges are ok).  If there is already another
 /// predecessor of the succ that is empty (and thus has no phi nodes), use it
@@ -275,9 +277,15 @@
   assert(isa<PHINode>(Dest->begin()) &&
          "This should only be called if Dest has a PHI!");
   
+  // As a hack, never split backedges of loops.  Even though the copy for any
+  // PHIs inserted on the backedge would be dead for exits from the loop, we
+  // assume that the cost of *splitting* the backedge would be too high.
+  if (DontHackBackedge && Dest == TIBB)
+    return;
+  
   /// TIPHIValues - This array is lazily computed to determine the values of
   /// PHIs in Dest that TI would provide.
-  std::vector<Value*> TIPHIValues;
+  SmallVector<Value*, 32> TIPHIValues;
   
   // Check to see if Dest has any blocks that can be used as a split edge for
   // this terminator.





More information about the llvm-commits mailing list