PPC/s390: [turbofan] Refactor the compare-zero folding in instruction selector.

Port 9b308dcaf5

R=jarin@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, bjaideep@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com
BUG=

Review-Url: https://codereview.chromium.org/2470043006
Cr-Commit-Position: refs/heads/master@{#40774}
This commit is contained in:
ziyang 2016-11-04 08:30:43 -07:00 committed by Commit bot
parent 9906b3e677
commit bbab241ca1
2 changed files with 26 additions and 26 deletions

View File

@ -1602,21 +1602,22 @@ void VisitFloat64Compare(InstructionSelector* selector, Node* node,
void VisitWordCompareZero(InstructionSelector* selector, Node* user,
Node* value, InstructionCode opcode,
FlagsContinuation* cont) {
while (selector->CanCover(user, value)) {
switch (value->opcode()) {
case IrOpcode::kWord32Equal: {
// Combine with comparisons against 0 by simply inverting the
// continuation.
// Try to combine with comparisons against 0 by simply inverting the branch.
while (value->opcode() == IrOpcode::kWord32Equal &&
selector->CanCover(user, value)) {
Int32BinopMatcher m(value);
if (m.right().Is(0)) {
if (!m.right().Is(0)) break;
user = value;
value = m.left().node();
cont->Negate();
continue;
}
if (selector->CanCover(user, value)) {
switch (value->opcode()) {
case IrOpcode::kWord32Equal:
cont->OverwriteAndNegateIfEqual(kEqual);
return VisitWord32Compare(selector, value, cont);
}
case IrOpcode::kInt32LessThan:
cont->OverwriteAndNegateIfEqual(kSignedLessThan);
return VisitWord32Compare(selector, value, cont);
@ -1738,7 +1739,6 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
default:
break;
}
break;
}
// Branch could not be combined with a compare, emit compare against 0.

View File

@ -1607,21 +1607,22 @@ void VisitFloat64Compare(InstructionSelector* selector, Node* node,
void VisitWordCompareZero(InstructionSelector* selector, Node* user,
Node* value, InstructionCode opcode,
FlagsContinuation* cont) {
while (selector->CanCover(user, value)) {
switch (value->opcode()) {
case IrOpcode::kWord32Equal: {
// Combine with comparisons against 0 by simply inverting the
// continuation.
// Try to combine with comparisons against 0 by simply inverting the branch.
while (value->opcode() == IrOpcode::kWord32Equal &&
selector->CanCover(user, value)) {
Int32BinopMatcher m(value);
if (m.right().Is(0)) {
if (!m.right().Is(0)) break;
user = value;
value = m.left().node();
cont->Negate();
continue;
}
if (selector->CanCover(user, value)) {
switch (value->opcode()) {
case IrOpcode::kWord32Equal:
cont->OverwriteAndNegateIfEqual(kEqual);
return VisitWord32Compare(selector, value, cont);
}
case IrOpcode::kInt32LessThan:
cont->OverwriteAndNegateIfEqual(kSignedLessThan);
return VisitWord32Compare(selector, value, cont);
@ -1740,7 +1741,6 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
default:
break;
}
break;
}
// Branch could not be combined with a compare, emit compare against 0.