Reviewers: Mads Ager, Kevin Millikin,

Message:
Emit literal zero as xor is used in few places but while browsing through the
code I found that it is not so everywhere.

I ran the benchmarks (crypto, deltablue and friends) with and without my change
and detected no performance regression.

Thank you!
Martin

Description:
Change codegen for literals to emit xor when literal is zero.

BUG=
TEST=

Please review this at http://codereview.chromium.org/6016007/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ia32/full-codegen-ia32.cc
  M src/ia32/lithium-codegen-ia32.cc
  M src/ia32/macro-assembler-ia32.h
  M src/ia32/macro-assembler-ia32.cc


Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 13a11777ab6ebec10d9c74bcaafd9c8f972ce0c3..5beec0d387e5233e7c503ac25e16d32448c338d7 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -379,7 +379,7 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {

 void FullCodeGenerator::AccumulatorValueContext::Plug(
     Handle<Object> lit) const {
-  __ mov(result_register(), lit);
+  __ Set(result_register(), Immediate(lit));
 }


Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index d64f528e71c9a6d92221b2741df9c5cf4f82f7dd..2fbd95bdd8f4a91eed578b98587dccd1c1666389 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -940,7 +940,7 @@ void LCodeGen::DoSubI(LSubI* instr) {

 void LCodeGen::DoConstantI(LConstantI* instr) {
   ASSERT(instr->result()->IsRegister());
-  __ mov(ToRegister(instr->result()), instr->value());
+  __ Set(ToRegister(instr->result()), instr->value());
 }


@@ -973,7 +973,7 @@ void LCodeGen::DoConstantD(LConstantD* instr) {

 void LCodeGen::DoConstantT(LConstantT* instr) {
   ASSERT(instr->result()->IsRegister());
-  __ mov(ToRegister(instr->result()), Immediate(instr->value()));
+  __ Set(ToRegister(instr->result()), Immediate(instr->value()));
 }


Index: src/ia32/macro-assembler-ia32.cc
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 7c339065274b18b3d0eb932e98c934560e1d332f..682e14d5a8ab17a042f951b62a4e1e53726facfe 100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -178,6 +178,15 @@ void MacroAssembler::Set(Register dst, const Immediate& x) {
 }


+void MacroAssembler::Set(Register dst, int32_t imm32) {
+  if (imm32 == 0) {
+    xor_(dst, Operand(dst));
+  } else {
+    mov(dst, imm32);
+  }
+}
+
+
 void MacroAssembler::Set(const Operand& dst, const Immediate& x) {
   mov(dst, x);
 }
Index: src/ia32/macro-assembler-ia32.h
diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h index 6f5fa87297191df91f483cb736d4baf598918308..5ed1d15a0cd9954fd47ad89a5f5f822fe67bab5c 100644
--- a/src/ia32/macro-assembler-ia32.h
+++ b/src/ia32/macro-assembler-ia32.h
@@ -188,6 +188,7 @@ class MacroAssembler: public Assembler {

   // Expression support
   void Set(Register dst, const Immediate& x);
+  void Set(Register dst, int32_t imm32);
   void Set(const Operand& dst, const Immediate& x);

   // Compare object type for heap object.


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to