Really eliminate a|0 and b&(-1)
authorLars Knoll <lars.knoll@digia.com>
Sun, 9 Feb 2014 20:11:16 +0000 (21:11 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 22 Feb 2014 15:48:00 +0000 (16:48 +0100)
The old code wasn't doing what it promised to do
and failed to remove these expressions.

Change-Id: I6718539fd528f293db537e47ff1c9ac4b27ada55
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/compiler/qv4ssa.cpp

index dcee3ea..83d0f24 100644 (file)
@@ -3367,16 +3367,16 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses, DominatorTree &
                         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;
+                            if (leftConst && !rightConst && QV4::Primitive::toUInt32(leftConst->value) == 0xffffffff)
+                                casted = binop->right;
+                            else if (!leftConst && rightConst && QV4::Primitive::toUInt32(rightConst->value) == 0xffffffff)
+                                casted = binop->left;
                             break;
                         case OpBitOr:
-                            if (leftConst && !rightConst && leftConst->value == 0)
-                                casted = rightConst;
-                            else if (!leftConst && rightConst && rightConst->value == 0)
-                                casted = leftConst;
+                            if (leftConst && !rightConst && QV4::Primitive::toInt32(leftConst->value) == 0)
+                                casted = binop->right;
+                            else if (!leftConst && rightConst && QV4::Primitive::toUInt32(rightConst->value) == 0)
+                                casted = binop->left;
                             break;
                         default:
                             break;