diff options
author | Erik Verbruggen <[email protected]> | 2013-10-04 11:55:38 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-10-10 09:54:12 +0200 |
commit | 42aa10adc93068acbcdc503342c8db92c5b5b899 (patch) | |
tree | 06c153615ee85bf476c5e51c12c503b236807098 /src/qml/compiler/qv4ssa.cpp | |
parent | e34477bfaf318fe26cd935728eeec144cc1659fa (diff) |
V4: Remove more jumps.
Do not generate jump instructions when the target immediately follows
the current basic block, even if there are intermediate jumps in between
as long as they jump to the same basic block. In the IR snippet below,
no jumps will be generated at all.
…
L8: goto L6;
L12: goto L6;
L6: goto L4;
L11: goto L4;
L4: goto L2;
L10: goto L2;
L2: ….
Before this change, the gotos in L8, L6, and L2 were still generated.
Change-Id: I718ed0d41c603a6905f2279b782cd9e9cafb7d55
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r-- | src/qml/compiler/qv4ssa.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 6ad9a5731f..c41c9cfe80 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -2976,6 +2976,45 @@ QVector<LifeTimeInterval> Optimizer::lifeRanges() const return lifeRanges.ranges(); } +QSet<Jump *> Optimizer::calculateOptionalJumps() +{ + QSet<Jump *> optional; + QSet<BasicBlock *> reachableWithoutJump; + + const int maxSize = function->basicBlocks.size(); + optional.reserve(maxSize); + reachableWithoutJump.reserve(maxSize); + + for (int i = function->basicBlocks.size() - 1; i >= 0; --i) { + BasicBlock *bb = function->basicBlocks[i]; + + if (Jump *jump = bb->statements.last()->asJump()) { + if (reachableWithoutJump.contains(jump->target)) { + if (bb->statements.size() > 1) + reachableWithoutJump.clear(); + optional.insert(jump); + reachableWithoutJump.insert(bb); + continue; + } + } + + reachableWithoutJump.clear(); + reachableWithoutJump.insert(bb); + } + +#if 0 + QTextStream out(stdout, QIODevice::WriteOnly); + out << "Jumps to ignore:" << endl; + foreach (Jump *j, removed) { + out << "\t" << j->id << ": "; + j->dump(out, Stmt::MIR); + out << endl; + } +#endif + + return optional; +} + void Optimizer::showMeTheCode(Function *function) { ::showMeTheCode(function); |