aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4ssa.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-03-14 10:17:27 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-19 08:14:53 +0100
commit44ca5f1be03420978cc8d5468c4c40dcd5174a06 (patch)
tree7d30284402d23fd448af568895a1753d64ab2a7a /src/qml/compiler/qv4ssa.cpp
parentcfd3eda076e81d56f985c830663ae93317b6ef8b (diff)
Enable constant propagation for all types
So far constant propagation was only enabled for numbers and booleans. Enable it for all types now and make sure the propagation does the right thing. Change-Id: I202b0073f463d8a42e34931a736544207284b6dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r--src/qml/compiler/qv4ssa.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index ca0bbb1bb3..338041ad5d 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -2305,6 +2305,10 @@ void convertConst(Const *c, Type targetType)
case BoolType:
c->value = !(c->value == 0 || std::isnan(c->value));
break;
+ case NullType:
+ case UndefinedType:
+ c->value = qSNaN();
+ c->type = targetType;
default:
Q_UNIMPLEMENTED();
Q_ASSERT(!"Unimplemented!");
@@ -2991,6 +2995,11 @@ private:
}
}
+ if (e1->type == IR::NullType && e2->type == IR::NullType)
+ return true;
+ if (e1->type == IR::UndefinedType && e2->type == IR::UndefinedType)
+ return true;
+
return false;
}
};
@@ -3116,18 +3125,20 @@ bool tryOptimizingComparison(Expr *&expr)
expr = leftConst;
return true;
case OpStrictEqual:
- if (!strictlyEqualTypes(leftConst->type, rightConst->type))
- return false;
- // intentional fall-through
+ leftConst->value = Runtime::compareStrictEqual(&l, &r);
+ leftConst->type = BoolType;
+ expr = leftConst;
+ return true;
case OpEqual:
leftConst->value = Runtime::compareEqual(&l, &r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpStrictNotEqual:
- if (!strictlyEqualTypes(leftConst->type, rightConst->type))
- return false;
- // intentional fall-through
+ leftConst->value = Runtime::compareStrictNotEqual(&l, &r);
+ leftConst->type = BoolType;
+ expr = leftConst;
+ return true;
case OpNotEqual:
leftConst->value = Runtime::compareNotEqual(&l, &r);
leftConst->type = BoolType;
@@ -3214,13 +3225,9 @@ void optimizeSSA(IR::Function *function, DefUsesCalculator &defUses, DominatorTr
// constant propagation:
if (Const *sourceConst = m->source->asConst()) {
- if (sourceConst->type & NumberType || sourceConst->type == BoolType) {
- // TODO: when propagating other constants, e.g. undefined, the other
- // optimization passes have to be changed to cope with them.
- W += replaceUses(targetTemp, sourceConst);
- defUses.removeDef(*targetTemp);
- W.clear(s);
- }
+ W += replaceUses(targetTemp, sourceConst);
+ defUses.removeDef(*targetTemp);
+ W.clear(s);
continue;
}
if (Member *member = m->source->asMember()) {