[llvm-commits] [llvm] r89381 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Nov 19 11:42:16 PST 2009


Author: stoklund
Date: Thu Nov 19 13:42:16 2009
New Revision: 89381

URL: http://llvm.org/viewvc/llvm-project?rev=89381&view=rev
Log:
Place new basic blocks immediately after their predecessor when splitting
critical edges in PHIElimination.

This has a huge impact on regalloc performance, and we recover almost all of
the 10% compile time regression that edge splitting introduced.

Modified:
    llvm/trunk/lib/CodeGen/PHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=89381&r1=89380&r2=89381&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Thu Nov 19 13:42:16 2009
@@ -439,21 +439,21 @@
   ++NumSplits;
 
   MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
-  MF->push_back(NMBB);
+  MF->insert(next(MachineFunction::iterator(A)), NMBB);
   DEBUG(errs() << "PHIElimination splitting critical edge:"
         " BB#" << A->getNumber()
         << " -- BB#" << NMBB->getNumber()
         << " -- BB#" << B->getNumber() << '\n');
 
   A->ReplaceUsesOfBlockWith(B, NMBB);
-  // If A may fall through to B, we may have to insert a branch.
-  if (A->isLayoutSuccessor(B))
-    A->updateTerminator();
+  A->updateTerminator();
 
-  // Insert unconditional "jump B" instruction in NMBB.
+  // Insert unconditional "jump B" instruction in NMBB if necessary.
   NMBB->addSuccessor(B);
-  Cond.clear();
-  MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
+  if (!NMBB->isLayoutSuccessor(B)) {
+    Cond.clear();
+    MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
+  }
 
   // Fix PHI nodes in B so they refer to NMBB instead of A
   for (MachineBasicBlock::iterator i = B->begin(), e = B->end();





More information about the llvm-commits mailing list