size_t output_count = 0;
// TODO(turbofan): match complex addressing modes.
- if (g.CanBeImmediate(right)) {
+ if (left == right) {
+ // If both inputs refer to the same operand, enforce allocating a register
+ // for both of them to ensure that we don't end up generating code like
+ // this:
+ //
+ // mov eax, [ebp-0x10]
+ // add eax, [ebp-0x10]
+ // jo label
+ InstructionOperand* const input = g.UseRegister(left);
+ inputs[input_count++] = input;
+ inputs[input_count++] = input;
+ } else if (g.CanBeImmediate(right)) {
inputs[input_count++] = g.UseRegister(left);
inputs[input_count++] = g.UseImmediate(right);
} else {
}
-static void VisitWordTest(InstructionSelector* selector, Node* node,
- FlagsContinuation* cont) {
- IA32OperandGenerator g(selector);
- VisitCompare(selector, kIA32Test, g.Use(node), g.TempImmediate(-1), cont);
-}
-
-
// Shared routine for multiple float compare operations.
static void VisitFloat64Compare(InstructionSelector* selector, Node* node,
FlagsContinuation* cont) {
void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
BasicBlock* fbranch) {
- OperandGenerator g(this);
+ IA32OperandGenerator g(this);
Node* user = branch;
Node* value = branch->InputAt(0);
}
// Branch could not be combined with a compare, emit compare against 0.
- VisitWordTest(this, value, &cont);
+ VisitCompare(this, kIA32Cmp, g.Use(value), g.TempImmediate(0), &cont);
}
default:
break;
}
- return VisitWordTest(this, value, &cont);
}
}
return VisitWordCompare(this, node, kIA32Cmp, &cont, false);
size_t output_count = 0;
// TODO(turbofan): match complex addressing modes.
- if (g.CanBeImmediate(right)) {
+ if (left == right) {
+ // If both inputs refer to the same operand, enforce allocating a register
+ // for both of them to ensure that we don't end up generating code like
+ // this:
+ //
+ // mov rax, [rbp-0x10]
+ // add rax, [rbp-0x10]
+ // jo label
+ InstructionOperand* const input = g.UseRegister(left);
+ inputs[input_count++] = input;
+ inputs[input_count++] = input;
+ } else if (g.CanBeImmediate(right)) {
inputs[input_count++] = g.UseRegister(left);
inputs[input_count++] = g.UseImmediate(right);
} else {
}
-static void VisitWordTest(InstructionSelector* selector, Node* node,
- InstructionCode opcode, FlagsContinuation* cont) {
- X64OperandGenerator g(selector);
- VisitCompare(selector, opcode, g.Use(node), g.TempImmediate(-1), cont);
-}
-
-
static void VisitFloat64Compare(InstructionSelector* selector, Node* node,
FlagsContinuation* cont) {
X64OperandGenerator g(selector);
void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
BasicBlock* fbranch) {
- OperandGenerator g(this);
+ X64OperandGenerator g(this);
Node* user = branch;
Node* value = branch->InputAt(0);
break;
case IrOpcode::kInt32Sub:
return VisitWordCompare(this, value, kX64Cmp32, &cont, false);
+ case IrOpcode::kInt64Sub:
+ return VisitWordCompare(this, value, kX64Cmp, &cont, false);
case IrOpcode::kWord32And:
return VisitWordCompare(this, value, kX64Test32, &cont, true);
+ case IrOpcode::kWord64And:
+ return VisitWordCompare(this, value, kX64Test, &cont, true);
default:
break;
}
}
// Branch could not be combined with a compare, emit compare against 0.
- VisitWordTest(this, value, kX64Test32, &cont);
+ VisitCompare(this, kX64Cmp32, g.Use(value), g.TempImmediate(0), &cont);
}
default:
break;
}
- return VisitWordTest(this, value, kX64Test32, &cont);
}
}
VisitWordCompare(this, node, kX64Cmp32, &cont, false);
default:
break;
}
- return VisitWordTest(this, value, kX64Test, &cont);
}
}
VisitWordCompare(this, node, kX64Cmp, &cont, false);