[llvm-commits] [llvm] r51183 - /llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
Evan Cheng
evan.cheng at apple.com
Fri May 16 00:55:50 PDT 2008
Author: evancheng
Date: Fri May 16 02:55:50 2008
New Revision: 51183
URL: http://llvm.org/viewvc/llvm-project?rev=51183&view=rev
Log:
Do not dup malloc, vector instructions, etc. Throttle the default theshold way down.
Modified:
llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=51183&r1=51182&r2=51183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Fri May 16 02:55:50 2008
@@ -39,8 +39,9 @@
STATISTIC(NumEliminated, "Number of unconditional branches eliminated");
static cl::opt<unsigned>
-Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"),
- cl::init(6), cl::Hidden);
+TailDupThreshold("taildup-threshold",
+ cl::desc("Max block size to tail duplicate"),
+ cl::init(1), cl::Hidden);
namespace {
class VISIBILITY_HIDDEN TailDup : public FunctionPass {
@@ -50,7 +51,7 @@
TailDup() : FunctionPass((intptr_t)&ID) {}
private:
- inline bool shouldEliminateUnconditionalBranch(TerminatorInst *TI);
+ inline bool shouldEliminateUnconditionalBranch(TerminatorInst *, unsigned);
inline void eliminateUnconditionalBranch(BranchInst *BI);
SmallPtrSet<BasicBlock*, 4> CycleDetector;
};
@@ -70,7 +71,8 @@
bool Changed = false;
CycleDetector.clear();
for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
- if (shouldEliminateUnconditionalBranch(I->getTerminator())) {
+ if (shouldEliminateUnconditionalBranch(I->getTerminator(),
+ TailDupThreshold)) {
eliminateUnconditionalBranch(cast<BranchInst>(I->getTerminator()));
Changed = true;
} else {
@@ -90,7 +92,8 @@
/// We don't count PHI nodes in the count since they will be removed when the
/// contents of the block are copied over.
///
-bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) {
+bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI,
+ unsigned Threshold) {
BranchInst *BI = dyn_cast<BranchInst>(TI);
if (!BI || !BI->isUnconditional()) return false; // Not an uncond branch!
@@ -124,6 +127,13 @@
// Don't tail duplicate call instructions. They are very large compared to
// other instructions.
if (isa<CallInst>(I) || isa<InvokeInst>(I)) return false;
+
+ // Allso alloca and malloc.
+ if (isa<AllocationInst>(I)) return false;
+
+ // Some vector instructions can expand into a number of instructions.
+ if (isa<ShuffleVectorInst>(I) || isa<ExtractElementInst>(I) ||
+ isa<InsertElementInst>(I)) return false;
// Only count instructions that are not debugger intrinsics.
if (!isa<DbgInfoIntrinsic>(I)) ++Size;
More information about the llvm-commits
mailing list