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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/instruction-selector-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 case kRepFloat32: 223 case kRepFloat32:
224 opcode = kCheckedLoadFloat32; 224 opcode = kCheckedLoadFloat32;
225 break; 225 break;
226 case kRepFloat64: 226 case kRepFloat64:
227 opcode = kCheckedLoadFloat64; 227 opcode = kCheckedLoadFloat64;
228 break; 228 break;
229 default: 229 default:
230 UNREACHABLE(); 230 UNREACHABLE();
231 return; 231 return;
232 } 232 }
233 InstructionOperand* offset_operand = g.UseRegister(offset); 233 if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
234 Int32Matcher mlength(length);
235 Int32BinopMatcher moffset(offset);
236 if (mlength.HasValue() && moffset.right().HasValue() &&
237 mlength.Value() >= moffset.right().Value()) {
238 Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer),
239 g.UseRegister(moffset.left().node()),
240 g.UseImmediate(moffset.right().node()), g.UseImmediate(length));
241 return;
242 }
243 }
234 InstructionOperand* length_operand = 244 InstructionOperand* length_operand =
235 g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length); 245 g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
236 Emit(opcode | AddressingModeField::encode(kMode_MR1), 246 Emit(opcode, g.DefineAsRegister(node), g.UseRegister(buffer),
237 g.DefineAsRegister(node), offset_operand, length_operand, 247 g.UseRegister(offset), g.TempImmediate(0), length_operand);
238 g.UseRegister(buffer), offset_operand);
239 } 248 }
240 249
241 250
242 void InstructionSelector::VisitCheckedStore(Node* node) { 251 void InstructionSelector::VisitCheckedStore(Node* node) {
243 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); 252 MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
244 X64OperandGenerator g(this); 253 X64OperandGenerator g(this);
245 Node* const buffer = node->InputAt(0); 254 Node* const buffer = node->InputAt(0);
246 Node* const offset = node->InputAt(1); 255 Node* const offset = node->InputAt(1);
247 Node* const length = node->InputAt(2); 256 Node* const length = node->InputAt(2);
248 Node* const value = node->InputAt(3); 257 Node* const value = node->InputAt(3);
(...skipping 13 matching lines...) Expand all
262 break; 271 break;
263 case kRepFloat64: 272 case kRepFloat64:
264 opcode = kCheckedStoreFloat64; 273 opcode = kCheckedStoreFloat64;
265 break; 274 break;
266 default: 275 default:
267 UNREACHABLE(); 276 UNREACHABLE();
268 return; 277 return;
269 } 278 }
270 InstructionOperand* value_operand = 279 InstructionOperand* value_operand =
271 g.CanBeImmediate(value) ? g.UseImmediate(value) : g.UseRegister(value); 280 g.CanBeImmediate(value) ? g.UseImmediate(value) : g.UseRegister(value);
272 InstructionOperand* offset_operand = g.UseRegister(offset); 281 if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
282 Int32Matcher mlength(length);
283 Int32BinopMatcher moffset(offset);
284 if (mlength.HasValue() && moffset.right().HasValue() &&
285 mlength.Value() >= moffset.right().Value()) {
286 Emit(opcode, nullptr, g.UseRegister(buffer),
287 g.UseRegister(moffset.left().node()),
288 g.UseImmediate(moffset.right().node()), g.UseImmediate(length),
289 value_operand);
290 return;
291 }
292 }
273 InstructionOperand* length_operand = 293 InstructionOperand* length_operand =
274 g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length); 294 g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
275 Emit(opcode | AddressingModeField::encode(kMode_MR1), nullptr, offset_operand, 295 Emit(opcode, nullptr, g.UseRegister(buffer), g.UseRegister(offset),
276 length_operand, value_operand, g.UseRegister(buffer), offset_operand); 296 g.TempImmediate(0), length_operand, value_operand);
277 } 297 }
278 298
279 299
280 // Shared routine for multiple binary operations. 300 // Shared routine for multiple binary operations.
281 static void VisitBinop(InstructionSelector* selector, Node* node, 301 static void VisitBinop(InstructionSelector* selector, Node* node,
282 InstructionCode opcode, FlagsContinuation* cont) { 302 InstructionCode opcode, FlagsContinuation* cont) {
283 X64OperandGenerator g(selector); 303 X64OperandGenerator g(selector);
284 Int32BinopMatcher m(node); 304 Int32BinopMatcher m(node);
285 Node* left = m.left().node(); 305 Node* left = m.left().node();
286 Node* right = m.right().node(); 306 Node* right = m.right().node();
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 MachineOperatorBuilder::kFloat64Ceil | 1305 MachineOperatorBuilder::kFloat64Ceil |
1286 MachineOperatorBuilder::kFloat64RoundTruncate | 1306 MachineOperatorBuilder::kFloat64RoundTruncate |
1287 MachineOperatorBuilder::kWord32ShiftIsSafe; 1307 MachineOperatorBuilder::kWord32ShiftIsSafe;
1288 } 1308 }
1289 return MachineOperatorBuilder::kNoFlags; 1309 return MachineOperatorBuilder::kNoFlags;
1290 } 1310 }
1291 1311
1292 } // namespace compiler 1312 } // namespace compiler
1293 } // namespace internal 1313 } // namespace internal
1294 } // namespace v8 1314 } // namespace v8
OLDNEW
« 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