aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4ssa.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2014-05-13 13:05:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-06 14:50:20 +0200
commitf99ddc62ea468bff2700860e30d29be91d74473e (patch)
tree13d20adfac92f501378073536e6f736faf7a5f1e /src/qml/compiler/qv4ssa.cpp
parent0ee38bbecb0bd31683e5f73b3fec2a8129bf0894 (diff)
V4 IR: add def statements to the worklist when removing uses.
When removing a phi node, add the def statement for the (previously) used temps to the worklist. These statements might now be eligible for further optimizations (specifically removal when there are no uses left). Change-Id: I05d7c7bc0a243d328b5f9d1c2dcc53a10bd7491d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r--src/qml/compiler/qv4ssa.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 82a69b3224..9149c757b6 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -3107,8 +3107,10 @@ void purgeBB(BasicBlock *bb, IR::Function *func, DefUses &defUses, StatementWork
if (!outStmt)
continue;
if (Phi *phi = outStmt->asPhi()) {
- if (Temp *t = phi->d->incoming[idx]->asTemp())
+ if (Temp *t = phi->d->incoming[idx]->asTemp()) {
defUses.removeUse(phi, *t);
+ W += defUses.defStmt(*t);
+ }
phi->d->incoming.remove(idx);
W += phi;
} else
@@ -3215,6 +3217,13 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df)
Q_ASSERT(s);
if (Phi *phi = s->asPhi()) {
+ // dead code elimination:
+ if (defUses.useCount(*phi->targetTemp) == 0) {
+ W += defUses.removeDefUses(phi);
+ W.remove(s);
+ continue;
+ }
+
// constant propagation:
if (Const *c = isConstPhi(phi)) {
replaceUses(phi->targetTemp, c, W);
@@ -3233,23 +3242,12 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df)
if (Temp *t2 = e->asTemp()) {
defUses.removeUse(s, *t2);
defUses.addUses(*t2, newT2Uses);
+ W += defUses.defStmt(*t2);
}
defUses.removeDef(*t);
W.remove(s);
continue;
}
-
- // dead code elimination:
- if (defUses.useCount(*phi->targetTemp) == 0) {
- foreach (Expr *in, phi->d->incoming) {
- if (Temp *t = in->asTemp())
- W += defUses.defStmt(*t);
- }
-
- defUses.removeDef(*phi->targetTemp);
- W.remove(s);
- continue;
- }
} else if (Move *m = s->asMove()) {
if (Convert *convert = m->source->asConvert()) {
if (Const *sourceConst = convert->expr->asConst()) {