V4 SSA: cleanup: rename single letter variables.
authorErik Verbruggen <erik.verbruggen@me.com>
Sat, 21 Sep 2013 16:56:52 +0000 (18:56 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 25 Sep 2013 07:46:25 +0000 (09:46 +0200)
Because "targetTemp" and "sourceTemp" is clearer than, say, t1 and t2.

Change-Id: I5195c75f1958a3bea3c370924685ff6ba9c9c515
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qv4ssa.cpp

index 805edd7..f39517b 100644 (file)
@@ -2276,14 +2276,14 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
                 continue;
             }
         } else  if (Move *m = s->asMove()) {
-            if (Temp *t = unescapableTemp(m->target, variablesCanEscape)) {
+            if (Temp *targetTemp = unescapableTemp(m->target, variablesCanEscape)) {
                 // constant propagation:
-                if (Const *c = m->source->asConst()) {
-                    if (c->type & NumberType || c->type == BoolType) {
+                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(t, c);
-                        defUses.removeDef(*t);
+                        W += replaceUses(targetTemp, sourceConst);
+                        defUses.removeDef(*targetTemp);
                         *ref[s] = 0;
                     }
                     continue;
@@ -2300,63 +2300,63 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
 #endif
 
                 // copy propagation:
-                if (Temp *t2 = unescapableTemp(m->source, variablesCanEscape)) {
-                    QVector<Stmt *> newT2Uses = replaceUses(t, t2);
+                if (Temp *sourceTemp = unescapableTemp(m->source, variablesCanEscape)) {
+                    QVector<Stmt *> newT2Uses = replaceUses(targetTemp, sourceTemp);
                     W += newT2Uses;
-                    defUses.removeUse(s, *t2);
-                    defUses.addUses(*t2, QList<Stmt*>::fromVector(newT2Uses));
-                    defUses.removeDef(*t);
+                    defUses.removeUse(s, *sourceTemp);
+                    defUses.addUses(*sourceTemp, QList<Stmt*>::fromVector(newT2Uses));
+                    defUses.removeDef(*targetTemp);
                     *ref[s] = 0;
                     continue;
                 }
 
-                if (Unop *u = m->source->asUnop()) {
+                if (Unop *unop = m->source->asUnop()) {
                     // Constant unary expression evaluation:
-                    if (Const *c = u->expr->asConst()) {
-                        if (c->type & NumberType || c->type == BoolType) {
+                    if (Const *constOperand = unop->expr->asConst()) {
+                        if (constOperand->type & NumberType || constOperand->type == BoolType) {
                             // TODO: implement unop propagation for other constant types
                             bool doneSomething = false;
-                            switch (u->op) {
+                            switch (unop->op) {
                             case OpNot:
-                                c->value = !c->value;
-                                c->type = BoolType;
+                                constOperand->value = !constOperand->value;
+                                constOperand->type = BoolType;
                                 doneSomething = true;
                                 break;
                             case OpUMinus:
-                                if (int(c->value) == 0 && int(c->value) == c->value) {
-                                    if (isNegative(c->value))
-                                        c->value = 0;
+                                if (int(constOperand->value) == 0 && int(constOperand->value) == constOperand->value) {
+                                    if (isNegative(constOperand->value))
+                                        constOperand->value = 0;
                                     else
-                                        c->value = -1 / Q_INFINITY;
-                                    c->type = DoubleType;
+                                        constOperand->value = -1 / Q_INFINITY;
+                                    constOperand->type = DoubleType;
                                     doneSomething = true;
                                     break;
                                 }
 
-                                c->value = -c->value;
-                                if (canConvertToSignedInteger(c->value))
-                                    c->type = SInt32Type;
-                                else if (canConvertToUnsignedInteger(c->value))
-                                    c->type = UInt32Type;
+                                constOperand->value = -constOperand->value;
+                                if (canConvertToSignedInteger(constOperand->value))
+                                    constOperand->type = SInt32Type;
+                                else if (canConvertToUnsignedInteger(constOperand->value))
+                                    constOperand->type = UInt32Type;
                                 else
-                                    c->type = DoubleType;
+                                    constOperand->type = DoubleType;
                                 doneSomething = true;
                                 break;
                             case OpUPlus:
-                                c->type = DoubleType;
+                                constOperand->type = DoubleType;
                                 doneSomething = true;
                                 break;
                             case OpCompl:
-                                c->value = ~QV4::Value::toInt32(c->value);
-                                c->type = SInt32Type;
+                                constOperand->value = ~QV4::Value::toInt32(constOperand->value);
+                                constOperand->type = SInt32Type;
                                 doneSomething = true;
                                 break;
                             case OpIncrement:
-                                c->value = c->value + 1;
+                                constOperand->value = constOperand->value + 1;
                                 doneSomething = true;
                                 break;
                             case OpDecrement:
-                                c->value = c->value - 1;
+                                constOperand->value = constOperand->value - 1;
                                 doneSomething = true;
                                 break;
                             default:
@@ -2364,7 +2364,7 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
                             };
 
                             if (doneSomething) {
-                                m->source = c;
+                                m->source = constOperand;
                                 W += m;
                             }
                         }
@@ -2375,14 +2375,14 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
                     continue;
                 }
 
-                if (Binop *b = m->source->asBinop()) {
+                if (Binop *binop = m->source->asBinop()) {
                     // 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 = b->left->asConst();
+                    Const *leftConst = binop->left->asConst();
                     if (!leftConst || leftConst->type == StringType || leftConst->type == VarType)
                         continue;
-                    Const *rightConst = b->right->asConst();
+                    Const *rightConst = binop->right->asConst();
                     if (!rightConst || rightConst->type == StringType || rightConst->type == VarType)
                         continue;
 
@@ -2391,7 +2391,7 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
                     double l = __qmljs_to_number(&lc);
                     double r = __qmljs_to_number(&rc);
 
-                    switch (b->op) {
+                    switch (binop->op) {
                     case OpMul:
                         leftConst->value = l * r;
                         leftConst->type = DoubleType;
@@ -2430,14 +2430,14 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
 
                     continue;
                 }
-            }
+            } // TODO: var{#0} = double{%10} where %10 is defined once and used once. E.g.: function(t){t = t % 2; return t; }
 
         } else if (CJump *cjump = s->asCJump()) {
-            if (Const *c = cjump->cond->asConst()) {
+            if (Const *constantCondition = cjump->cond->asConst()) {
                 // Note: this assumes that there are no critical edges! Meaning, we can safely purge
                 //       any basic blocks that are found to be unreachable.
                 Jump *jump = function->New<Jump>();
-                if (convertToValue(c).toBoolean()) {
+                if (convertToValue(constantCondition).toBoolean()) {
                     jump->target = cjump->iftrue;
                     purgeBB(cjump->iffalse, function, defUses, W);
                 } else {