Commit 3c79e2e9 authored by Benedikt Meurer's avatar Benedikt Meurer

[x64] Recognize MOVSXWL.

Also add some debug code to verify correct zero extension of 32-bit
moves.

TEST=mjsunit/asm
R=svenpanne@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25385}
parent 58839390
......@@ -484,6 +484,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break;
case kX64Movsxbl:
__ movsxbl(i.OutputRegister(), i.MemoryOperand());
__ AssertZeroExtended(i.OutputRegister());
break;
case kX64Movzxbl:
__ movzxbl(i.OutputRegister(), i.MemoryOperand());
......@@ -499,10 +500,18 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break;
}
case kX64Movsxwl:
__ movsxwl(i.OutputRegister(), i.MemoryOperand());
if (instr->addressing_mode() != kMode_None) {
__ movsxwl(i.OutputRegister(), i.MemoryOperand());
} else if (instr->InputAt(0)->IsRegister()) {
__ movsxwl(i.OutputRegister(), i.InputRegister(0));
} else {
__ movsxwl(i.OutputRegister(), i.InputOperand(0));
}
__ AssertZeroExtended(i.OutputRegister());
break;
case kX64Movzxwl:
__ movzxwl(i.OutputRegister(), i.MemoryOperand());
__ AssertZeroExtended(i.OutputRegister());
break;
case kX64Movw: {
int index = 0;
......@@ -525,6 +534,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
} else {
__ movl(i.OutputRegister(), i.MemoryOperand());
}
__ AssertZeroExtended(i.OutputRegister());
} else {
int index = 0;
Operand operand = i.MemoryOperand(&index);
......@@ -576,6 +586,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break;
case kX64Lea32:
__ leal(i.OutputRegister(), i.MemoryOperand());
__ AssertZeroExtended(i.OutputRegister());
break;
case kX64Lea:
__ leaq(i.OutputRegister(), i.MemoryOperand());
......
......@@ -346,6 +346,15 @@ void InstructionSelector::VisitWord64Shr(Node* node) {
void InstructionSelector::VisitWord32Sar(Node* node) {
X64OperandGenerator g(this);
Int32BinopMatcher m(node);
if (CanCover(m.node(), m.left().node()) && m.left().IsWord32Shl()) {
Int32BinopMatcher mleft(m.left().node());
if (mleft.right().Is(16) && m.right().Is(16)) {
Emit(kX64Movsxwl, g.DefineAsRegister(node), g.Use(mleft.left().node()));
return;
}
}
VisitWord32Shift(this, node, kX64Sar32);
}
......@@ -364,6 +373,7 @@ void InstructionSelector::VisitWord64Ror(Node* node) {
VisitWord64Shift(this, node, kX64Ror);
}
namespace {
AddressingMode GenerateMemoryOperandInputs(X64OperandGenerator* g, Node* scaled,
......@@ -1161,6 +1171,7 @@ InstructionSelector::SupportedMachineOperatorFlags() {
}
return MachineOperatorBuilder::kNoFlags;
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -1401,6 +1401,15 @@ void Assembler::movsxbq(Register dst, const Operand& src) {
}
void Assembler::movsxwl(Register dst, Register src) {
EnsureSpace ensure_space(this);
emit_optional_rex_32(dst, src);
emit(0x0F);
emit(0xBF);
emit_modrm(dst, src);
}
void Assembler::movsxwl(Register dst, const Operand& src) {
EnsureSpace ensure_space(this);
emit_optional_rex_32(dst, src);
......
......@@ -733,6 +733,7 @@ class Assembler : public AssemblerBase {
void movsxbl(Register dst, const Operand& src);
void movsxbq(Register dst, const Operand& src);
void movsxwl(Register dst, Register src);
void movsxwl(Register dst, const Operand& src);
void movsxwq(Register dst, const Operand& src);
void movsxlq(Register dst, Register src);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment