Commit db7580a4 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Refactor the compare-zero folding in instruction selector.

  port 9b308dca (r40721)

  original commit message:

BUG=

Review-Url: https://codereview.chromium.org/2485033002
Cr-Commit-Position: refs/heads/master@{#40818}
parent 7d28301d
......@@ -1433,22 +1433,22 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
// Shared routine for word comparison with zero.
void VisitWordCompareZero(InstructionSelector* selector, Node* user,
Node* value, FlagsContinuation* cont) {
// Try to combine the branch with a comparison.
while (selector->CanCover(user, value)) {
// 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)) break;
user = value;
value = m.left().node();
cont->Negate();
}
if (selector->CanCover(user, value)) {
switch (value->opcode()) {
case IrOpcode::kWord32Equal: {
// Try to combine with comparisons against 0 by simply inverting the
// continuation.
Int32BinopMatcher m(value);
if (m.right().Is(0)) {
user = value;
value = m.left().node();
cont->Negate();
continue;
}
case IrOpcode::kWord32Equal:
cont->OverwriteAndNegateIfEqual(kEqual);
return VisitWordCompare(selector, value, cont);
}
case IrOpcode::kInt32LessThan:
cont->OverwriteAndNegateIfEqual(kSignedLessThan);
return VisitWordCompare(selector, value, cont);
......@@ -1514,7 +1514,6 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
default:
break;
}
break;
}
// Continuation could not be combined with a compare, emit compare against 0.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment