Commit d401543f authored by shiyu.zhang's avatar shiyu.zhang Committed by Commit bot

[ia32] Optimize index calculation for certain checked load/stores.

It reduces the add operation for certain checked load/stores by pre-do
the add in compiling phase.

BUG=

Review-Url: https://codereview.chromium.org/2593483002
Cr-Commit-Position: refs/heads/master@{#43128}
parent 340c64af
This diff is collapsed.
......@@ -395,6 +395,30 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
UNREACHABLE();
return;
}
if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
Int32BinopMatcher moffset(offset);
InstructionOperand buffer_operand = g.CanBeImmediate(buffer)
? g.UseImmediate(buffer)
: g.UseRegister(buffer);
Int32Matcher mlength(length);
if (mlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() >= 0 &&
mlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.DefineAsRegister(node),
g.UseImmediate(moffset.right().node()), g.UseImmediate(length),
g.UseRegister(moffset.left().node()), buffer_operand);
return;
}
IntMatcher<int32_t, IrOpcode::kRelocatableInt32Constant> mmlength(length);
if (mmlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() >= 0 &&
mmlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.DefineAsRegister(node),
g.UseImmediate(moffset.right().node()), g.UseImmediate(length),
g.UseRegister(moffset.left().node()), buffer_operand);
return;
}
}
InstructionOperand offset_operand = g.UseRegister(offset);
InstructionOperand length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
......@@ -450,6 +474,30 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
rep == MachineRepresentation::kBit)
? g.UseByteRegister(value)
: g.UseRegister(value));
if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
Int32BinopMatcher moffset(offset);
InstructionOperand buffer_operand = g.CanBeImmediate(buffer)
? g.UseImmediate(buffer)
: g.UseRegister(buffer);
Int32Matcher mlength(length);
if (mlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() >= 0 &&
mlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.NoOutput(), g.UseImmediate(moffset.right().node()),
g.UseImmediate(length), value_operand,
g.UseRegister(moffset.left().node()), buffer_operand);
return;
}
IntMatcher<int32_t, IrOpcode::kRelocatableInt32Constant> mmlength(length);
if (mmlength.HasValue() && moffset.right().HasValue() &&
moffset.right().Value() >= 0 &&
mmlength.Value() >= moffset.right().Value()) {
Emit(opcode, g.NoOutput(), g.UseImmediate(moffset.right().node()),
g.UseImmediate(length), value_operand,
g.UseRegister(moffset.left().node()), buffer_operand);
return;
}
}
InstructionOperand offset_operand = g.UseRegister(offset);
InstructionOperand length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
......
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