Avoid some unneccesary instructions in swapValues
authorLars Knoll <lars.knoll@digia.com>
Sun, 9 Feb 2014 19:09:10 +0000 (20:09 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 22 Feb 2014 15:47:46 +0000 (16:47 +0100)
If source and target values are of the same type, there's no need
to write the type to the stack once again.

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

index b355969450715c77ca41fc3e41c7c78f9724711c..157cbd3634837ec5bbbd29a1af9f777eb3b3581b 100644 (file)
@@ -1201,20 +1201,22 @@ void InstructionSelection::swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *target
     } else {
         _as->load32(addr, Assembler::ScratchRegister);
         _as->store32((Assembler::RegisterID) registerTemp->index, addr);
-        addr.offset += 4;
-        quint32 tag;
-        switch (registerTemp->type) {
-        case V4IR::BoolType:
-            tag = QV4::Value::_Boolean_Type;
-            break;
-        case V4IR::SInt32Type:
-            tag = QV4::Value::_Integer_Type;
-            break;
-        default:
-            tag = QV4::Value::Undefined_Type;
-            Q_UNREACHABLE();
+        if (registerTemp->type != stackTemp->type) {
+            addr.offset += 4;
+            quint32 tag;
+            switch (registerTemp->type) {
+            case V4IR::BoolType:
+                tag = QV4::Value::_Boolean_Type;
+                break;
+            case V4IR::SInt32Type:
+                tag = QV4::Value::_Integer_Type;
+                break;
+            default:
+                tag = QV4::Value::Undefined_Type;
+                Q_UNREACHABLE();
+            }
+            _as->store32(Assembler::TrustedImm32(tag), addr);
         }
-        _as->store32(Assembler::TrustedImm32(tag), addr);
         _as->move(Assembler::ScratchRegister, (Assembler::RegisterID) registerTemp->index);
     }
 }