You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2007/05/08 14:30:21 UTC

svn commit: r536177 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32: Ia32InstCodeSelector.cpp Ia32PeepHole.cpp

Author: varlax
Date: Tue May  8 05:30:20 2007
New Revision: 536177

URL: http://svn.apache.org/viewvc?view=rev&rev=536177
Log:
Applied HARMONY-3794 [drlvm][jit][opt] Minor code quality improvements: peephole and RA-related

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?view=diff&rev=536177&r1=536176&r2=536177
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Tue May  8 05:30:20 2007
@@ -2704,7 +2704,7 @@
         Opnd* ecxOpnd = irManager.newOpnd(opnds[2]->getType(), cecx);
 #else
         Opnd* eaxOpnd = irManager.getRegOpnd(RegName_EAX);
-        Opnd* ecxOpnd = irManager.getRegOpnd(RegName_ECX);
+        Opnd* ecxOpnd = irManager.newOpnd(typeManager.getUInt32Type(), Constraint(OpndKind_GPReg));
 #endif
         Opnd* memOpnd = irManager.newMemOpnd(opnds[1]->getType(), opnds[0]);//use opnd1 type for memopnd
         appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, eaxOpnd, opnds[1]));

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp?view=diff&rev=536177&r1=536176&r2=536177
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp Tue May  8 05:30:20 2007
@@ -91,6 +91,7 @@
     Changed handleInst_MUL(Inst* inst);
     Changed handleInst_SSEMov(Inst* inst);
     Changed handleInst_SSEXor(Inst* inst);
+    Changed handleInst_CMP(Inst* inst);
     //
     // Helpers
     //
@@ -177,6 +178,8 @@
 
 PeepHoleOpt::Changed PeepHoleOpt::handleInst(Inst* inst)
 {
+    PeepHoleOpt::Changed temp;
+
     if (isPseudoInst(inst)) {
         return Changed_Nothing;
     }
@@ -191,9 +194,15 @@
     case Mnemonic_AND:
     case Mnemonic_OR:
     case Mnemonic_XOR:
-    case Mnemonic_CMP:
     case Mnemonic_TEST:
         return handleInst_ALU(inst);
+    case Mnemonic_CMP:
+    temp = handleInst_CMP(inst);
+    if ( temp == Changed_Nothing ) {
+        return handleInst_ALU(inst); 
+    } else {
+        return temp;
+    }
     case Mnemonic_IMUL:
     case Mnemonic_MUL:
         return handleInst_MUL(inst);
@@ -404,6 +413,29 @@
     } while (--i>=0);
     return i;
 }
+
+PeepHoleOpt::Changed PeepHoleOpt::handleInst_CMP(Inst* inst) {
+    assert(inst->getMnemonic()==Mnemonic_CMP);
+    
+    Inst::Opnds uses(inst, Inst::OpndRole_Explicit | Inst::OpndRole_Use);
+    Opnd* src1 = inst->getOpnd(uses.begin());
+    Opnd* src2 = inst->getOpnd(uses.next(uses.begin()));
+    assert(src1!=NULL && src2!=NULL);
+
+    if (isImm(src1)) {
+        Opnd* tmp = src1; src1 = src2; src2 = tmp;
+    }
+
+    if (isImm(src2) && isReg(src1) && (int)src2->getImmValue() == 0) {
+            if (Log::isEnabled()) Log::out()<<"I"<<inst->getId()<<" -> CMP with 0"<<std::endl;
+            irManager->newInst(Mnemonic_TEST, src1, src1)->insertAfter(inst);
+            inst->unlink();
+            return Changed_Inst;
+    }
+    return Changed_Nothing;
+}
+
+
 
 PeepHoleOpt::Changed PeepHoleOpt::handleInst_MUL(Inst* inst) {
     assert(inst->getMnemonic()==Mnemonic_IMUL || inst->getMnemonic()==Mnemonic_MUL);