Commit b881465d authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Simplify representation inference for add/subtract.

We don't really care about signedness when truncating to Word32.

Review URL: https://codereview.chromium.org/1417023005

Cr-Commit-Position: refs/heads/master@{#31779}
parent 86be3280
...@@ -474,32 +474,23 @@ class RepresentationSelector { ...@@ -474,32 +474,23 @@ class RepresentationSelector {
bool CanLowerToInt32Binop(Node* node, MachineTypeUnion use) { bool CanLowerToInt32Binop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, Type::Signed32()) && return BothInputsAre(node, Type::Signed32()) &&
(!CanObserveNonInt32(use) || (!CanObserveNonWord32(use) ||
NodeProperties::GetType(node)->Is(Type::Signed32())); NodeProperties::GetType(node)->Is(Type::Signed32()));
} }
bool CanLowerToInt32AdditiveBinop(Node* node, MachineTypeUnion use) { bool CanLowerToWord32AdditiveBinop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, safe_int_additive_range_) && return BothInputsAre(node, safe_int_additive_range_) &&
!CanObserveNonInt32(use); !CanObserveNonWord32(use);
} }
bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, Type::Unsigned32()) && return BothInputsAre(node, Type::Unsigned32()) &&
(!CanObserveNonUint32(use) || (!CanObserveNonWord32(use) ||
NodeProperties::GetType(node)->Is(Type::Unsigned32())); NodeProperties::GetType(node)->Is(Type::Unsigned32()));
} }
bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) {
return BothInputsAre(node, safe_int_additive_range_) &&
!CanObserveNonUint32(use);
}
bool CanObserveNonWord32(MachineTypeUnion use) { bool CanObserveNonWord32(MachineTypeUnion use) {
return (use & ~(kTypeUint32 | kTypeInt32)) != 0; return (use & kTypeMask & ~(kTypeInt32 | kTypeUint32)) != 0;
}
bool CanObserveNonInt32(MachineTypeUnion use) {
return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0;
} }
bool CanObserveMinusZero(MachineTypeUnion use) { bool CanObserveMinusZero(MachineTypeUnion use) {
...@@ -511,10 +502,6 @@ class RepresentationSelector { ...@@ -511,10 +502,6 @@ class RepresentationSelector {
return (use & (kTypeNumber | kTypeAny)) != 0; return (use & (kTypeNumber | kTypeAny)) != 0;
} }
bool CanObserveNonUint32(MachineTypeUnion use) {
return (use & (kTypeInt32 | kTypeNumber | kTypeAny)) != 0;
}
// Dispatching routine for visiting the node {node} with the usage {use}. // Dispatching routine for visiting the node {node} with the usage {use}.
// Depending on the operator, propagate new usage info to the inputs. // Depending on the operator, propagate new usage info to the inputs.
void VisitNode(Node* node, MachineTypeUnion use, void VisitNode(Node* node, MachineTypeUnion use,
...@@ -644,22 +631,16 @@ class RepresentationSelector { ...@@ -644,22 +631,16 @@ class RepresentationSelector {
// => signed Int32Add/Sub // => signed Int32Add/Sub
VisitInt32Binop(node); VisitInt32Binop(node);
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
} else if (CanLowerToInt32AdditiveBinop(node, use)) {
// => signed Int32Add/Sub, truncating inputs
ProcessTruncateWord32Input(node, 0, kTypeInt32);
ProcessTruncateWord32Input(node, 1, kTypeInt32);
SetOutput(node, kMachInt32);
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
} else if (CanLowerToUint32Binop(node, use)) { } else if (CanLowerToUint32Binop(node, use)) {
// => unsigned Int32Add/Sub // => unsigned Int32Add/Sub
VisitUint32Binop(node); VisitUint32Binop(node);
if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
} else if (CanLowerToUint32AdditiveBinop(node, use)) { } else if (CanLowerToWord32AdditiveBinop(node, use)) {
// => signed Int32Add/Sub, truncating inputs // => signed Int32Add/Sub, truncating inputs
ProcessTruncateWord32Input(node, 0, kTypeUint32); ProcessTruncateWord32Input(node, 0, kTypeInt32);
ProcessTruncateWord32Input(node, 1, kTypeUint32); ProcessTruncateWord32Input(node, 1, kTypeInt32);
SetOutput(node, kMachUint32); SetOutput(node, kMachInt32);
if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
} else { } else {
// => Float64Add/Sub // => Float64Add/Sub
VisitFloat64Binop(node); VisitFloat64Binop(node);
......
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