diff options
author | Erik Verbruggen <[email protected]> | 2013-12-02 16:57:32 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-12-03 09:50:59 +0100 |
commit | 0fa3b4c23c96c9375c8a1b8e4981e1b84188a3ef (patch) | |
tree | d795d3d111499bfcb44bf10049ecabb89727c266 /src/qml/compiler/qv4ssa.cpp | |
parent | 7fdc5c34a5ea0ba2c98e63aa78094991d44c8f51 (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 <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r-- | src/qml/compiler/qv4ssa.cpp | 31 |
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; |