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

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

Issue 2470043006: PPC/s390: [turbofan] Refactor the compare-zero folding in instruction selector. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | src/compiler/s390/instruction-selector-s390.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/ppc/frames-ppc.h" 9 #include "src/ppc/frames-ppc.h"
10 10
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 Node* right = node->InputAt(1); 1595 Node* right = node->InputAt(1);
1596 VisitCompare(selector, kPPC_CmpDouble, g.UseRegister(left), 1596 VisitCompare(selector, kPPC_CmpDouble, g.UseRegister(left),
1597 g.UseRegister(right), cont); 1597 g.UseRegister(right), cont);
1598 } 1598 }
1599 1599
1600 1600
1601 // Shared routine for word comparisons against zero. 1601 // Shared routine for word comparisons against zero.
1602 void VisitWordCompareZero(InstructionSelector* selector, Node* user, 1602 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
1603 Node* value, InstructionCode opcode, 1603 Node* value, InstructionCode opcode,
1604 FlagsContinuation* cont) { 1604 FlagsContinuation* cont) {
1605 while (selector->CanCover(user, value)) { 1605 // Try to combine with comparisons against 0 by simply inverting the branch.
1606 while (value->opcode() == IrOpcode::kWord32Equal &&
1607 selector->CanCover(user, value)) {
1608 Int32BinopMatcher m(value);
1609 if (!m.right().Is(0)) break;
1610
1611 user = value;
1612 value = m.left().node();
1613 cont->Negate();
1614 }
1615
1616 if (selector->CanCover(user, value)) {
1606 switch (value->opcode()) { 1617 switch (value->opcode()) {
1607 case IrOpcode::kWord32Equal: { 1618 case IrOpcode::kWord32Equal:
1608 // Combine with comparisons against 0 by simply inverting the
1609 // continuation.
1610 Int32BinopMatcher m(value);
1611 if (m.right().Is(0)) {
1612 user = value;
1613 value = m.left().node();
1614 cont->Negate();
1615 continue;
1616 }
1617 cont->OverwriteAndNegateIfEqual(kEqual); 1619 cont->OverwriteAndNegateIfEqual(kEqual);
1618 return VisitWord32Compare(selector, value, cont); 1620 return VisitWord32Compare(selector, value, cont);
1619 }
1620 case IrOpcode::kInt32LessThan: 1621 case IrOpcode::kInt32LessThan:
1621 cont->OverwriteAndNegateIfEqual(kSignedLessThan); 1622 cont->OverwriteAndNegateIfEqual(kSignedLessThan);
1622 return VisitWord32Compare(selector, value, cont); 1623 return VisitWord32Compare(selector, value, cont);
1623 case IrOpcode::kInt32LessThanOrEqual: 1624 case IrOpcode::kInt32LessThanOrEqual:
1624 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 1625 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
1625 return VisitWord32Compare(selector, value, cont); 1626 return VisitWord32Compare(selector, value, cont);
1626 case IrOpcode::kUint32LessThan: 1627 case IrOpcode::kUint32LessThan:
1627 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); 1628 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
1628 return VisitWord32Compare(selector, value, cont); 1629 return VisitWord32Compare(selector, value, cont);
1629 case IrOpcode::kUint32LessThanOrEqual: 1630 case IrOpcode::kUint32LessThanOrEqual:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 // case IrOpcode::kWord64Or: 1732 // case IrOpcode::kWord64Or:
1732 // case IrOpcode::kWord64Xor: 1733 // case IrOpcode::kWord64Xor:
1733 // case IrOpcode::kWord64Sar: 1734 // case IrOpcode::kWord64Sar:
1734 // case IrOpcode::kWord64Shl: 1735 // case IrOpcode::kWord64Shl:
1735 // case IrOpcode::kWord64Shr: 1736 // case IrOpcode::kWord64Shr:
1736 // case IrOpcode::kWord64Ror: 1737 // case IrOpcode::kWord64Ror:
1737 #endif 1738 #endif
1738 default: 1739 default:
1739 break; 1740 break;
1740 } 1741 }
1741 break;
1742 } 1742 }
1743 1743
1744 // Branch could not be combined with a compare, emit compare against 0. 1744 // Branch could not be combined with a compare, emit compare against 0.
1745 PPCOperandGenerator g(selector); 1745 PPCOperandGenerator g(selector);
1746 VisitCompare(selector, opcode, g.UseRegister(value), g.TempImmediate(0), 1746 VisitCompare(selector, opcode, g.UseRegister(value), g.TempImmediate(0),
1747 cont); 1747 cont);
1748 } 1748 }
1749 1749
1750 1750
1751 void VisitWord32CompareZero(InstructionSelector* selector, Node* user, 1751 void VisitWord32CompareZero(InstructionSelector* selector, Node* user,
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 // static 2093 // static
2094 MachineOperatorBuilder::AlignmentRequirements 2094 MachineOperatorBuilder::AlignmentRequirements
2095 InstructionSelector::AlignmentRequirements() { 2095 InstructionSelector::AlignmentRequirements() {
2096 return MachineOperatorBuilder::AlignmentRequirements:: 2096 return MachineOperatorBuilder::AlignmentRequirements::
2097 FullUnalignedAccessSupport(); 2097 FullUnalignedAccessSupport();
2098 } 2098 }
2099 2099
2100 } // namespace compiler 2100 } // namespace compiler
2101 } // namespace internal 2101 } // namespace internal
2102 } // namespace v8 2102 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/s390/instruction-selector-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698