[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}
This commit is contained in:
jarin 2015-11-04 02:53:35 -08:00 committed by Commit bot
parent 86be328096
commit b881465d7c

View File

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