From f99ddc62ea468bff2700860e30d29be91d74473e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 13 May 2014 13:05:25 +0200 Subject: 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 --- src/qml/compiler/qv4ssa.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/qml/compiler') 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()) { -- cgit v1.2.3