Improve generated code for HDoCompareObjectEqAndBranch on ia32/x64
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Apr 2013 09:53:49 +0000 (09:53 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Apr 2013 09:53:49 +0000 (09:53 +0000)
R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/14083008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14324 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ia32/lithium-codegen-ia32.cc
src/ia32/lithium-ia32.cc
src/x64/lithium-codegen-x64.cc
src/x64/lithium-x64.cc

index 1dcad04..bc6f5cb 100644 (file)
@@ -2287,11 +2287,15 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
 
 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
   Register left = ToRegister(instr->left());
-  Operand right = ToOperand(instr->right());
   int false_block = chunk_->LookupDestination(instr->false_block_id());
   int true_block = chunk_->LookupDestination(instr->true_block_id());
 
-  __ cmp(left, Operand(right));
+  if (instr->right()->IsConstantOperand()) {
+    __ cmp(left, ToHandle(LConstantOperand::cast(instr->right())));
+  } else {
+    Operand right = ToOperand(instr->right());
+    __ cmp(left, Operand(right));
+  }
   EmitBranch(true_block, false_block, equal);
 }
 
index a7bb2d9..aa1d5c9 100644 (file)
@@ -1693,7 +1693,7 @@ LInstruction* LChunkBuilder::DoCompareIDAndBranch(
 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
     HCompareObjectEqAndBranch* instr) {
   LOperand* left = UseRegisterAtStart(instr->left());
-  LOperand* right = UseAtStart(instr->right());
+  LOperand* right = UseOrConstantAtStart(instr->right());
   return new(zone()) LCmpObjectEqAndBranch(left, right);
 }
 
index 6fc56ed..fb5dd59 100644 (file)
@@ -2055,11 +2055,14 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
 
 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
   Register left = ToRegister(instr->left());
-  Register right = ToRegister(instr->right());
   int false_block = chunk_->LookupDestination(instr->false_block_id());
   int true_block = chunk_->LookupDestination(instr->true_block_id());
 
-  __ cmpq(left, right);
+  if (instr->right()->IsConstantOperand()) {
+    __ Cmp(left, ToHandle(LConstantOperand::cast(instr->right())));
+  } else {
+    __ cmpq(left, ToRegister(instr->right()));
+  }
   EmitBranch(true_block, false_block, equal);
 }
 
index ba29ed9..fe494f2 100644 (file)
@@ -1610,7 +1610,7 @@ LInstruction* LChunkBuilder::DoCompareIDAndBranch(
 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
     HCompareObjectEqAndBranch* instr) {
   LOperand* left = UseRegisterAtStart(instr->left());
-  LOperand* right = UseRegisterAtStart(instr->right());
+  LOperand* right = UseRegisterOrConstantAtStart(instr->right());
   return new(zone()) LCmpObjectEqAndBranch(left, right);
 }