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

Side by Side Diff: src/compiler/mips/instruction-selector-mips.cc

Issue 2475433005: [turbofan] Refactor the compare-zero folding in instruction selector. (Closed)
Patch Set: Make mips64 happy Created 4 years, 1 month 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1409
1410 1410
1411 void VisitWordCompare(InstructionSelector* selector, Node* node, 1411 void VisitWordCompare(InstructionSelector* selector, Node* node,
1412 FlagsContinuation* cont) { 1412 FlagsContinuation* cont) {
1413 VisitWordCompare(selector, node, kMipsCmp, cont, false); 1413 VisitWordCompare(selector, node, kMipsCmp, cont, false);
1414 } 1414 }
1415 1415
1416 // Shared routine for word comparisons against zero. 1416 // Shared routine for word comparisons against zero.
1417 void VisitWordCompareZero(InstructionSelector* selector, Node* user, 1417 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
1418 Node* value, FlagsContinuation* cont) { 1418 Node* value, FlagsContinuation* cont) {
1419 while (selector->CanCover(user, value)) { 1419 // Try to combine with comparisons against 0 by simply inverting the branch.
1420 while (value->opcode() == IrOpcode::kWord32Equal &&
1421 selector->CanCover(user, value)) {
1422 Int32BinopMatcher m(value);
1423 if (!m.right().Is(0)) break;
1424
1425 user = value;
1426 value = m.left().node();
1427 cont->Negate();
1428 }
1429
1430 if (selector->CanCover(user, value)) {
1420 switch (value->opcode()) { 1431 switch (value->opcode()) {
1421 case IrOpcode::kWord32Equal: { 1432 case IrOpcode::kWord32Equal:
1422 // Combine with comparisons against 0 by simply inverting the
1423 // continuation.
1424 Int32BinopMatcher m(value);
1425 if (m.right().Is(0)) {
1426 user = value;
1427 value = m.left().node();
1428 cont->Negate();
1429 continue;
1430 }
1431 cont->OverwriteAndNegateIfEqual(kEqual); 1433 cont->OverwriteAndNegateIfEqual(kEqual);
1432 return VisitWordCompare(selector, value, cont); 1434 return VisitWordCompare(selector, value, cont);
1433 }
1434 case IrOpcode::kInt32LessThan: 1435 case IrOpcode::kInt32LessThan:
1435 cont->OverwriteAndNegateIfEqual(kSignedLessThan); 1436 cont->OverwriteAndNegateIfEqual(kSignedLessThan);
1436 return VisitWordCompare(selector, value, cont); 1437 return VisitWordCompare(selector, value, cont);
1437 case IrOpcode::kInt32LessThanOrEqual: 1438 case IrOpcode::kInt32LessThanOrEqual:
1438 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 1439 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
1439 return VisitWordCompare(selector, value, cont); 1440 return VisitWordCompare(selector, value, cont);
1440 case IrOpcode::kUint32LessThan: 1441 case IrOpcode::kUint32LessThan:
1441 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); 1442 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
1442 return VisitWordCompare(selector, value, cont); 1443 return VisitWordCompare(selector, value, cont);
1443 case IrOpcode::kUint32LessThanOrEqual: 1444 case IrOpcode::kUint32LessThanOrEqual:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 break; 1488 break;
1488 } 1489 }
1489 } 1490 }
1490 } 1491 }
1491 break; 1492 break;
1492 case IrOpcode::kWord32And: 1493 case IrOpcode::kWord32And:
1493 return VisitWordCompare(selector, value, kMipsTst, cont, true); 1494 return VisitWordCompare(selector, value, kMipsTst, cont, true);
1494 default: 1495 default:
1495 break; 1496 break;
1496 } 1497 }
1497 break;
1498 } 1498 }
1499 1499
1500 // Continuation could not be combined with a compare, emit compare against 0. 1500 // Continuation could not be combined with a compare, emit compare against 0.
1501 MipsOperandGenerator g(selector); 1501 MipsOperandGenerator g(selector);
1502 InstructionCode const opcode = cont->Encode(kMipsCmp); 1502 InstructionCode const opcode = cont->Encode(kMipsCmp);
1503 InstructionOperand const value_operand = g.UseRegister(value); 1503 InstructionOperand const value_operand = g.UseRegister(value);
1504 if (cont->IsBranch()) { 1504 if (cont->IsBranch()) {
1505 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), 1505 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0),
1506 g.Label(cont->true_block()), g.Label(cont->false_block())); 1506 g.Label(cont->true_block()), g.Label(cont->false_block()));
1507 } else if (cont->IsDeoptimize()) { 1507 } else if (cont->IsDeoptimize()) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) || 1807 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) ||
1808 IsMipsArchVariant(kMips32r2)); 1808 IsMipsArchVariant(kMips32r2));
1809 return MachineOperatorBuilder::AlignmentRequirements:: 1809 return MachineOperatorBuilder::AlignmentRequirements::
1810 NoUnalignedAccessSupport(); 1810 NoUnalignedAccessSupport();
1811 } 1811 }
1812 } 1812 }
1813 1813
1814 } // namespace compiler 1814 } // namespace compiler
1815 } // namespace internal 1815 } // namespace internal
1816 } // namespace v8 1816 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698