[turbofan] Further simplify representation inference for NumberTo(U)int32.

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

Cr-Commit-Position: refs/heads/master@{#32174}
This commit is contained in:
jarin 2015-11-23 04:30:11 -08:00 committed by Commit bot
parent 78174a426d
commit 134869fd24
2 changed files with 8 additions and 76 deletions

View File

@ -130,7 +130,8 @@ class UseInfo {
};
UseInfo UseInfoFromRepresentation(MachineTypeUnion rep) {
UseInfo UseInfoFromMachineType(MachineType type) {
MachineTypeUnion rep = RepresentationOf(type);
DCHECK((rep & kTypeMask) == 0);
if (rep & kRepTagged) return UseInfo::AnyTagged();
if (rep & kRepFloat64) {
@ -153,11 +154,6 @@ UseInfo UseInfoFromRepresentation(MachineTypeUnion rep) {
}
UseInfo UseInfoFromMachineType(MachineType type) {
return UseInfoFromRepresentation(RepresentationOf(type));
}
UseInfo UseInfoForBasePointer(const FieldAccess& access) {
return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::PointerInt();
}
@ -827,35 +823,15 @@ class RepresentationSelector {
break;
}
case IrOpcode::kNumberToInt32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
Type* in_upper = NodeProperties::GetType(input);
if (in_upper->Is(Type::Signed32())) {
// If the input has type int32, pass through representation.
VisitUnop(node, UseInfoFromRepresentation(use_rep),
kTypeInt32 | use_rep);
if (lower()) DeferReplacement(node, node->InputAt(0));
} else {
// Just change representation if necessary.
VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32);
if (lower()) DeferReplacement(node, node->InputAt(0));
}
// Just change representation if necessary.
VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32);
if (lower()) DeferReplacement(node, node->InputAt(0));
break;
}
case IrOpcode::kNumberToUint32: {
MachineTypeUnion use_rep = use & kRepMask;
Node* input = node->InputAt(0);
Type* in_upper = NodeProperties::GetType(input);
if (in_upper->Is(Type::Unsigned32())) {
// If the input has type uint32, pass through representation.
VisitUnop(node, UseInfoFromRepresentation(use_rep),
kTypeUint32 | use_rep);
if (lower()) DeferReplacement(node, node->InputAt(0));
} else {
// Just change representation if necessary.
VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32);
if (lower()) DeferReplacement(node, node->InputAt(0));
}
// Just change representation if necessary.
VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32);
if (lower()) DeferReplacement(node, node->InputAt(0));
break;
}
case IrOpcode::kNumberIsHoleNaN: {

View File

@ -1045,28 +1045,6 @@ static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) {
}
TEST(LowerNumberToInt32_to_nop) {
// NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepTagged
TestingGraph t(Type::Signed32());
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
Node* use = t.Use(trunc, kRepTagged);
t.Return(use);
t.Lower();
CHECK_EQ(t.p0, use->InputAt(0));
}
TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) {
// NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepFloat64
TestingGraph t(Type::Signed32());
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0);
Node* use = t.Use(trunc, kRepFloat64);
t.Return(use);
t.Lower();
CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0));
}
TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) {
// NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32
TestingGraph t(Type::Signed32());
@ -1105,28 +1083,6 @@ TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32_with_change) {
}
TEST(LowerNumberToUint32_to_nop) {
// NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepTagged
TestingGraph t(Type::Unsigned32());
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
Node* use = t.Use(trunc, kRepTagged);
t.Return(use);
t.Lower();
CHECK_EQ(t.p0, use->InputAt(0));
}
TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) {
// NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32
TestingGraph t(Type::Unsigned32());
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0);
Node* use = t.Use(trunc, kRepFloat64);
t.Return(use);
t.Lower();
CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0));
}
TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) {
// NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32
TestingGraph t(Type::Unsigned32());