Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index 05b3f254deaffc1a7c2b17bb5bd56fe2f8831d33..d2d1f376e1301fcbbaab95cc6210f59715c147bc 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -677,6 +677,12 @@ class RepresentationSelector { |
GetUpperBound(node->InputAt(1))->Is(type); |
} |
+ bool OneInputCannotBe(Node* node, Type* type) { |
Jarin
2016/08/02 20:02:09
I have to say this: Somehow, I see you adding new
|
+ DCHECK_EQ(2, node->op()->ValueInputCount()); |
+ return !GetUpperBound(node->InputAt(0))->Maybe(type) || |
+ !GetUpperBound(node->InputAt(1))->Maybe(type); |
+ } |
+ |
void ConvertInput(Node* node, int index, UseInfo use) { |
Node* input = node->InputAt(index); |
// In the change phase, insert a change before the use if necessary. |
@@ -1290,7 +1296,31 @@ class RepresentationSelector { |
} |
return; |
} |
- case IrOpcode::kNumberEqual: |
+ case IrOpcode::kNumberEqual: { |
+ // Number comparisons reduce to integer comparisons for integer inputs. |
+ if ((TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) && |
+ TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) || |
+ (BothInputsAre(node, type_cache_.kUnsigned32OrMinusZeroOrNaN) && |
+ OneInputCannotBe(node, type_cache_.kZeroish))) { |
+ // => unsigned Int32Cmp |
+ VisitUint32Cmp(node); |
+ if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); |
+ return; |
+ } |
+ if ((TypeOf(node->InputAt(0))->Is(Type::Signed32()) && |
+ TypeOf(node->InputAt(1))->Is(Type::Signed32())) || |
+ (BothInputsAre(node, type_cache_.kSigned32OrMinusZeroOrNaN) && |
+ OneInputCannotBe(node, type_cache_.kZeroish))) { |
+ // => signed Int32Cmp |
+ VisitInt32Cmp(node); |
+ if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
+ return; |
+ } |
+ // => Float64Cmp |
+ VisitFloat64Cmp(node); |
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
+ return; |
+ } |
case IrOpcode::kNumberLessThan: |
case IrOpcode::kNumberLessThanOrEqual: { |
// Number comparisons reduce to integer comparisons for integer inputs. |
@@ -1580,25 +1610,21 @@ class RepresentationSelector { |
if (BothInputsAre(node, Type::PlainPrimitive())) { |
if (truncation.IsUnused()) return VisitUnused(node); |
} |
- if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) { |
+ if (BothInputsAre(node, type_cache_.kUnsigned32OrMinusZeroOrNaN) && |
+ (truncation.IsUsedAsWord32() || |
+ NodeProperties::GetType(node)->Is(Type::Unsigned32()))) { |
// => unsigned Uint32Mod |
VisitWord32TruncatingBinop(node); |
if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); |
return; |
} |
- if (BothInputsAreSigned32(node)) { |
- if (NodeProperties::GetType(node)->Is(Type::Signed32())) { |
- // => signed Int32Mod |
- VisitInt32Binop(node); |
- if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
- return; |
- } |
- if (truncation.IsUsedAsWord32()) { |
- // => signed Int32Mod |
- VisitWord32TruncatingBinop(node); |
- if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
- return; |
- } |
+ if (BothInputsAre(node, type_cache_.kSigned32OrMinusZeroOrNaN) && |
+ (truncation.IsUsedAsWord32() || |
+ NodeProperties::GetType(node)->Is(Type::Signed32()))) { |
+ // => signed Int32Mod |
+ VisitWord32TruncatingBinop(node); |
+ if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
+ return; |
} |
// Try to use type feedback. |
@@ -1651,25 +1677,21 @@ class RepresentationSelector { |
return; |
} |
case IrOpcode::kNumberModulus: { |
- if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) { |
+ if (BothInputsAre(node, type_cache_.kUnsigned32OrMinusZeroOrNaN) && |
+ (truncation.IsUsedAsWord32() || |
+ NodeProperties::GetType(node)->Is(Type::Unsigned32()))) { |
// => unsigned Uint32Mod |
VisitWord32TruncatingBinop(node); |
if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); |
return; |
} |
- if (BothInputsAreSigned32(node)) { |
- if (NodeProperties::GetType(node)->Is(Type::Signed32())) { |
- // => signed Int32Mod |
- VisitInt32Binop(node); |
- if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
- return; |
- } |
- if (truncation.IsUsedAsWord32()) { |
- // => signed Int32Mod |
- VisitWord32TruncatingBinop(node); |
- if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
- return; |
- } |
+ if (BothInputsAre(node, type_cache_.kSigned32OrMinusZeroOrNaN) && |
+ (truncation.IsUsedAsWord32() || |
+ NodeProperties::GetType(node)->Is(Type::Signed32()))) { |
+ // => signed Int32Mod |
+ VisitWord32TruncatingBinop(node); |
+ if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); |
+ return; |
} |
// => Float64Mod |
VisitFloat64Binop(node); |