[llvm-branch-commits] [llvm-branch] r89276 - in /llvm/branches/Apple/Leela: lib/CodeGen/BranchFolding.cpp test/CodeGen/ARM/tail-opts.ll

Bob Wilson bob.wilson at apple.com
Wed Nov 18 15:56:27 PST 2009


Author: bwilson
Date: Wed Nov 18 17:56:27 2009
New Revision: 89276

URL: http://llvm.org/viewvc/llvm-project?rev=89276&view=rev
Log:
$ svn merge -c 89225 https://bwilson@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89225 into '.':
U    lib/CodeGen/BranchFolding.cpp
$ svn merge -c 89254 https://bwilson@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89254 into '.':
G    lib/CodeGen/BranchFolding.cpp
$ svn merge -c 89264 https://bwilson@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89264 into '.':
A    test/CodeGen/ARM/tail-opts.ll
G    lib/CodeGen/BranchFolding.cpp
$ svn merge -c 89274 https://bwilson@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89274 into '.':
U    test/CodeGen/ARM/tail-opts.ll
$ svn merge -c 89275 https://bwilson@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89275 into '.':
G    lib/CodeGen/BranchFolding.cpp

Added:
    llvm/branches/Apple/Leela/test/CodeGen/ARM/tail-opts.ll
      - copied, changed from r89264, llvm/trunk/test/CodeGen/ARM/tail-opts.ll
Modified:
    llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp

Modified: llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp?rev=89276&r1=89275&r2=89276&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/BranchFolding.cpp Wed Nov 18 17:56:27 2009
@@ -41,8 +41,12 @@
 STATISTIC(NumDeadBlocks, "Number of dead blocks removed");
 STATISTIC(NumBranchOpts, "Number of branches optimized");
 STATISTIC(NumTailMerge , "Number of block tails merged");
+STATISTIC(NumTailDups  , "Number of tail duplicated blocks");
+STATISTIC(NumInstrDups , "Additional instructions due to tail duplication");
+
 static cl::opt<cl::boolOrDefault> FlagEnableTailMerge("enable-tail-merge",
                               cl::init(cl::BOU_UNSET), cl::Hidden);
+
 // Throttle for huge numbers of predecessors (compile speed problems)
 static cl::opt<unsigned>
 TailMergeThreshold("tail-merge-threshold",
@@ -193,7 +197,6 @@
     MadeChange |= OptimizeImpDefsBlock(MBB);
   }
 
-
   bool MadeChangeThisIteration = true;
   while (MadeChangeThisIteration) {
     MadeChangeThisIteration = false;
@@ -202,10 +205,15 @@
     MadeChange |= MadeChangeThisIteration;
   }
 
-  // Do tail duplication once after tail merging is done.  Otherwise it is
+  // Do tail duplication after tail merging is done.  Otherwise it is
   // tough to avoid situations where tail duplication and tail merging undo
   // each other's transformations ad infinitum.
-  MadeChange |= TailDuplicateBlocks(MF);
+  MadeChangeThisIteration = true;
+  while (MadeChangeThisIteration) {
+    MadeChangeThisIteration = false;
+    MadeChangeThisIteration |= TailDuplicateBlocks(MF);
+    MadeChange |= MadeChangeThisIteration;
+  }
 
   // See if any jump tables have become mergable or dead as the code generator
   // did its thing.
@@ -1003,9 +1011,6 @@
 bool BranchFolder::TailDuplicateBlocks(MachineFunction &MF) {
   bool MadeChange = false;
 
-  // Make sure blocks are numbered in order
-  MF.RenumberBlocks();
-
   for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) {
     MachineBasicBlock *MBB = I++;
 
@@ -1017,6 +1022,7 @@
 
     // If it is dead, remove it.
     if (MBB->pred_empty()) {
+      NumInstrDups -= MBB->size();
       RemoveDeadBlock(MBB);
       MadeChange = true;
       ++NumDeadBlocks;
@@ -1097,6 +1103,7 @@
       MachineInstr *NewMI = MF.CloneMachineInstr(I);
       PredBB->insert(PredBB->end(), NewMI);
     }
+    NumInstrDups += TailBB->size() - 1; // subtract one for removed branch
 
     // Update the CFG.
     PredBB->removeSuccessor(PredBB->succ_begin());
@@ -1107,6 +1114,7 @@
        PredBB->addSuccessor(*I);
 
     Changed = true;
+    ++NumTailDups;
   }
 
   // If TailBB was duplicated into all its predecessors except for the prior

Copied: llvm/branches/Apple/Leela/test/CodeGen/ARM/tail-opts.ll (from r89264, llvm/trunk/test/CodeGen/ARM/tail-opts.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/CodeGen/ARM/tail-opts.ll?p2=llvm/branches/Apple/Leela/test/CodeGen/ARM/tail-opts.ll&p1=llvm/trunk/test/CodeGen/ARM/tail-opts.ll&r1=89264&r2=89276&rev=89276&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/ARM/tail-opts.ll (original)
+++ llvm/branches/Apple/Leela/test/CodeGen/ARM/tail-opts.ll Wed Nov 18 17:56:27 2009
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=arm -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s
+; RUN: llc < %s -mtriple=arm-apple-darwin -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s
 
 declare void @bar(i32)
 declare void @car(i32)





More information about the llvm-branch-commits mailing list