[llvm-branch-commits] [llvm-branch] r93602 - in /llvm/branches/Apple/Zoidberg: lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/TailDuplication.cpp lib/Transforms/Utils/LoopSimplify.cpp test/CodeGen/ARM/indirectbr.ll test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll

Bob Wilson bob.wilson at apple.com
Fri Jan 15 16:48:47 PST 2010


Author: bwilson
Date: Fri Jan 15 18:48:47 2010
New Revision: 93602

URL: http://llvm.org/viewvc/llvm-project?rev=93602&view=rev
Log:
--- Merging r93560 into '.':
U    lib/Transforms/Utils/LoopSimplify.cpp
--- Merging r93597 into '.':
U    test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll
U    test/CodeGen/ARM/indirectbr.ll
U    test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll
U    lib/CodeGen/LLVMTargetMachine.cpp
--- Merging r93600 into '.':
U    lib/CodeGen/TailDuplication.cpp

Modified:
    llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp
    llvm/branches/Apple/Zoidberg/lib/CodeGen/TailDuplication.cpp
    llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/branches/Apple/Zoidberg/test/CodeGen/ARM/indirectbr.ll
    llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll
    llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp?rev=93602&r1=93601&r2=93602&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp Fri Jan 15 18:48:47 2010
@@ -37,6 +37,8 @@
     cl::desc("Disable branch folding"));
 static cl::opt<bool> DisableTailDuplicate("disable-tail-duplicate", cl::Hidden,
     cl::desc("Disable tail duplication"));
+static cl::opt<bool> DisableEarlyTailDup("disable-early-taildup", cl::Hidden,
+    cl::desc("Disable pre-register allocation tail duplication"));
 static cl::opt<bool> DisableCodePlace("disable-code-place", cl::Hidden,
     cl::desc("Disable code placement"));
 static cl::opt<bool> DisableSSC("disable-ssc", cl::Hidden,
@@ -68,9 +70,6 @@
 EnableFastISelOption("fast-isel", cl::Hidden,
   cl::desc("Enable the \"fast\" instruction selector"));
 
-static cl::opt<bool> PreAllocTailDup("pre-regalloc-taildup", cl::Hidden,
-    cl::desc("Pre-register allocation tail duplication"));
-
 LLVMTargetMachine::LLVMTargetMachine(const Target &T,
                                      const std::string &TargetTriple)
   : TargetMachine(T) {
@@ -299,8 +298,7 @@
   }
 
   // Pre-ra tail duplication.
-  if (OptLevel != CodeGenOpt::None &&
-      !DisableTailDuplicate && PreAllocTailDup) {
+  if (OptLevel != CodeGenOpt::None && !DisableEarlyTailDup) {
     PM.add(createTailDuplicatePass(true));
     printAndVerify(PM, "After Pre-RegAlloc TailDuplicate",
                    /* allowDoubleDefs= */ true);

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/TailDuplication.cpp?rev=93602&r1=93601&r2=93602&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/TailDuplication.cpp Fri Jan 15 18:48:47 2010
@@ -433,28 +433,28 @@
 TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF,
                                  SmallVector<MachineBasicBlock*, 8> &TDBBs,
                                  SmallVector<MachineInstr*, 16> &Copies) {
-  // Pre-regalloc tail duplication hurts compile time and doesn't help
-  // much except for indirect branches.
-  bool hasIndirectBranch = (!TailBB->empty() &&
-                            TailBB->back().getDesc().isIndirectBranch());
-  if (PreRegAlloc && !hasIndirectBranch)
-    return false;
-
   // Set the limit on the number of instructions to duplicate, with a default
   // of one less than the tail-merge threshold. When optimizing for size,
   // duplicate only one, because one branch instruction can be eliminated to
   // compensate for the duplication.
   unsigned MaxDuplicateCount;
-  if (hasIndirectBranch)
+  if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
+    MaxDuplicateCount = 1;
+  else
+    MaxDuplicateCount = TailDuplicateSize;
+
+  if (PreRegAlloc) {
+      // Pre-regalloc tail duplication hurts compile time and doesn't help
+      // much except for indirect branches.
+    if (TailBB->empty() || !TailBB->back().getDesc().isIndirectBranch())
+      return false;
     // If the target has hardware branch prediction that can handle indirect
     // branches, duplicating them can often make them predictable when there
     // are common paths through the code.  The limit needs to be high enough
-    // to allow undoing the effects of tail merging.
+    // to allow undoing the effects of tail merging and other optimizations
+    // that rearrange the predecessors of the indirect branch.
     MaxDuplicateCount = 20;
-  else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
-    MaxDuplicateCount = 1;
-  else
-    MaxDuplicateCount = TailDuplicateSize;
+  }
 
   // Don't try to tail-duplicate single-block loops.
   if (TailBB->isSuccessor(TailBB))

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

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/LoopSimplify.cpp Fri Jan 15 18:48:47 2010
@@ -232,7 +232,7 @@
       PN->eraseFromParent();
     }
 
-  // If this loop has muliple exits and the exits all go to the same
+  // If this loop has multiple exits and the exits all go to the same
   // block, attempt to merge the exits. This helps several passes, such
   // as LoopRotation, which do not support loops with multiple exits.
   // SimplifyCFG also does this (and this code uses the same utility

Modified: llvm/branches/Apple/Zoidberg/test/CodeGen/ARM/indirectbr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/CodeGen/ARM/indirectbr.ll?rev=93602&r1=93601&r2=93602&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/CodeGen/ARM/indirectbr.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/CodeGen/ARM/indirectbr.ll Fri Jan 15 18:48:47 2010
@@ -12,6 +12,10 @@
 entry:
   %0 = load i8** @nextaddr, align 4               ; <i8*> [#uses=2]
   %1 = icmp eq i8* %0, null                       ; <i1> [#uses=1]
+; indirect branch gets duplicated here
+; ARM: bx
+; THUMB: mov pc, r1
+; THUMB2: mov pc, r1
   br i1 %1, label %bb3, label %bb2
 
 bb2:                                              ; preds = %entry, %bb3

Modified: llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll?rev=93602&r1=93601&r2=93602&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb/2009-12-17-pre-regalloc-taildup.ll Fri Jan 15 18:48:47 2010
@@ -1,4 +1,4 @@
-; RUN: llc -O3 -pre-regalloc-taildup < %s | FileCheck %s
+; RUN: llc -O3 < %s | FileCheck %s
 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32"
 target triple = "thumbv7-apple-darwin10"
 

Modified: llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll?rev=93602&r1=93601&r2=93602&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/CodeGen/Thumb2/2010-01-06-TailDuplicateLabels.ll Fri Jan 15 18:48:47 2010
@@ -1,4 +1,4 @@
-; RUN: llc -relocation-model=pic -pre-regalloc-taildup < %s | grep {:$} | sort | uniq -d | count 0
+; RUN: llc -relocation-model=pic < %s | grep {:$} | sort | uniq -d | count 0
 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32"
 target triple = "thumbv7-apple-darwin10"
 





More information about the llvm-branch-commits mailing list