Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 733893008: [x64] Fix optimization for certain checked load/stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/x64/code-generator-x64.cc ('k') | test/mjsunit/asm/float32array-negative-offset.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x64/instruction-selector-x64.cc
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc
index a8a9f9d58102dcd92ce69c7490f12218ce44317d..4c32255bac4524f353f5fdc9955129862d82626a 100644
--- a/src/compiler/x64/instruction-selector-x64.cc
+++ b/src/compiler/x64/instruction-selector-x64.cc
@@ -230,12 +230,21 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
UNREACHABLE();
return;
}
- InstructionOperand* offset_operand = g.UseRegister(offset);
+ if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
+ Int32Matcher mlength(length);
+ Int32BinopMatcher moffset(offset);
+ if (mlength.HasValue() && moffset.right().HasValue() &&
+ mlength.Value() >= moffset.right().Value()) {
+ Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer),
+ g.UseRegister(moffset.left().node()),
+ g.UseImmediate(moffset.right().node()), g.UseImmediate(length));
+ return;
+ }
+ }
InstructionOperand* length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
- Emit(opcode | AddressingModeField::encode(kMode_MR1),
- g.DefineAsRegister(node), offset_operand, length_operand,
- g.UseRegister(buffer), offset_operand);
+ Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer),
+ g.UseRegister(offset), g.TempImmediate(0), length_operand);
}
@@ -269,11 +278,22 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
}
InstructionOperand* value_operand =
g.CanBeImmediate(value) ? g.UseImmediate(value) : g.UseRegister(value);
- InstructionOperand* offset_operand = g.UseRegister(offset);
+ if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
+ Int32Matcher mlength(length);
+ Int32BinopMatcher moffset(offset);
+ if (mlength.HasValue() && moffset.right().HasValue() &&
+ mlength.Value() >= moffset.right().Value()) {
+ Emit(opcode, nullptr, g.UseRegister(buffer),
+ g.UseRegister(moffset.left().node()),
+ g.UseImmediate(moffset.right().node()), g.UseImmediate(length),
+ value_operand);
+ return;
+ }
+ }
InstructionOperand* length_operand =
g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
- Emit(opcode | AddressingModeField::encode(kMode_MR1), nullptr, offset_operand,
- length_operand, value_operand, g.UseRegister(buffer), offset_operand);
+ Emit(opcode, nullptr, g.UseRegister(buffer), g.UseRegister(offset),
+ g.TempImmediate(0), length_operand, value_operand);
}
« no previous file with comments | « src/compiler/x64/code-generator-x64.cc ('k') | test/mjsunit/asm/float32array-negative-offset.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698