aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-12-02 16:57:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-03 09:50:59 +0100
commit0fa3b4c23c96c9375c8a1b8e4981e1b84188a3ef (patch)
treed795d3d111499bfcb44bf10049ecabb89727c266 /src/qml/compiler
parent7fdc5c34a5ea0ba2c98e63aa78094991d44c8f51 (diff)
V4 IR: remove common toInt32 casts.
E.g.: a | 0 b & 0xffffffff These operations force the operands to be converted to int32 without changing their value. At this point we already added convert calls to the IR, so we can safely get rid of these operations. Change-Id: Ic4d3b989e13439eccd2c878fa7bf5030acae7630 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4ssa.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 051691e2ad..c2198c37de 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -2603,13 +2603,40 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
}
if (Binop *binop = m->source->asBinop()) {
+ Const *leftConst = binop->left->asConst();
+ Const *rightConst = binop->right->asConst();
+
+ { // Typical casts to int32:
+ Expr *casted = 0;
+ switch (binop->op) {
+ case OpBitAnd:
+ if (leftConst && !rightConst && leftConst->value == 0xffffffff)
+ casted = rightConst;
+ else if (!leftConst && rightConst && rightConst->value == 0xffffffff)
+ casted = leftConst;
+ break;
+ case OpBitOr:
+ if (leftConst && !rightConst && leftConst->value == 0)
+ casted = rightConst;
+ else if (!leftConst && rightConst && rightConst->value == 0)
+ casted = leftConst;
+ break;
+ default:
+ break;
+ }
+ if (casted) {
+ Q_ASSERT(casted->type == SInt32Type);
+ m->source = casted;
+ W += m;
+ continue;
+ }
+ }
+
// TODO: More constant binary expression evaluation
// TODO: If the result of the move is only used in one single cjump, then
// inline the binop into the cjump.
- Const *leftConst = binop->left->asConst();
if (!leftConst || leftConst->type == StringType || leftConst->type == VarType || leftConst->type == QObjectType)
continue;
- Const *rightConst = binop->right->asConst();
if (!rightConst || rightConst->type == StringType || rightConst->type == VarType || rightConst->type == QObjectType)
continue;