diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-01 07:05:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-01 07:05:07 +0000 |
commit | 8af7424920d9144ce80f0fd7dc1252a710141f66 (patch) | |
tree | 0a663468cbb5c430f8c95cc0c7d7e2146a5d8d36 /llvm/lib/Transforms/Scalar/TailDuplication.cpp | |
parent | 93d1e39f3e1fab11890a11d189f355033bdddde3 (diff) | |
download | bcm5719-llvm-8af7424920d9144ce80f0fd7dc1252a710141f66.tar.gz bcm5719-llvm-8af7424920d9144ce80f0fd7dc1252a710141f66.zip |
Speed up the tail duplication pass on the testcase below from 68.2s to 1.23s:
#define CL0(a) case a: f(); goto c;
#define CL1(a) CL0(a##0) CL0(a##1) CL0(a##2) CL0(a##3) CL0(a##4) CL0(a##5) \
CL0(a##6) CL0(a##7) CL0(a##8) CL0(a##9)
#define CL2(a) CL1(a##0) CL1(a##1) CL1(a##2) CL1(a##3) CL1(a##4) CL1(a##5) \
CL1(a##6) CL1(a##7) CL1(a##8) CL1(a##9)
#define CL3(a) CL2(a##0) CL2(a##1) CL2(a##2) CL2(a##3) CL2(a##4) CL2(a##5) \
CL2(a##6) CL2(a##7) CL2(a##8) CL2(a##9)
#define CL4(a) CL3(a##0) CL3(a##1) CL3(a##2) CL3(a##3) CL3(a##4) CL3(a##5) \
CL3(a##6) CL3(a##7) CL3(a##8) CL3(a##9)
void f();
void a() {
int b;
c: switch (b) {
CL4(1)
}
}
This comes from GCC PR 15524
llvm-svn: 17390
Diffstat (limited to 'llvm/lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailDuplication.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp index 85e1eac267e..545068b6dfb 100644 --- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp +++ b/llvm/lib/Transforms/Scalar/TailDuplication.cpp @@ -114,9 +114,14 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) { // with a single successor if the block has many other predecessors. This can // cause an N^2 explosion in CFG edges (and PHI node entries), as seen in // cases that have a large number of indirect gotos. - if (DTI->getNumSuccessors() > 8) - if (std::distance(PI, PE) * DTI->getNumSuccessors() > 128) - return false; + unsigned NumSuccs = DTI->getNumSuccessors(); + if (NumSuccs > 8) { + unsigned TooMany = 128; + if (NumSuccs >= TooMany) return false; + TooMany = TooMany/NumSuccs; + for (; PI != PE; ++PI) + if (TooMany-- == 0) return false; + } return true; } |