Commit 01cc19fa authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Handle word32 truncation in word32->tagged representation change.

Similarly to the word32->float64 case, we interpret word32 as uint32 if
the value is word32 truncated. This is fine because the users declared
they only care about mod 2^32 of the value (that's what word32
truncation means).

This CL also removes the ad-hoc handling of this situation
(https://codereview.chromium.org/2311903002).

BUG=chromium:644048

Review-Url: https://codereview.chromium.org/2312003005
Cr-Commit-Position: refs/heads/master@{#39224}
parent 595be2db
......@@ -149,7 +149,8 @@ Node* RepresentationChanger::GetRepresentationFor(
return GetTaggedPointerRepresentationFor(node, output_rep, output_type);
case MachineRepresentation::kTagged:
DCHECK(use_info.type_check() == TypeCheckKind::kNone);
return GetTaggedRepresentationFor(node, output_rep, output_type);
return GetTaggedRepresentationFor(node, output_rep, output_type,
use_info.truncation());
case MachineRepresentation::kFloat32:
DCHECK(use_info.type_check() == TypeCheckKind::kNone);
return GetFloat32RepresentationFor(node, output_rep, output_type,
......@@ -262,7 +263,8 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
}
Node* RepresentationChanger::GetTaggedRepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type) {
Node* node, MachineRepresentation output_rep, Type* output_type,
Truncation truncation) {
// Eagerly fold representation changes for constants.
switch (node->opcode()) {
case IrOpcode::kNumberConstant:
......@@ -312,7 +314,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
op = simplified()->ChangeInt31ToTaggedSigned();
} else if (output_type->Is(Type::Signed32())) {
op = simplified()->ChangeInt32ToTagged();
} else if (output_type->Is(Type::Unsigned32())) {
} else if (output_type->Is(Type::Unsigned32()) ||
truncation.IsUsedAsWord32()) {
// Either the output is uint32 or the uses only care about the
// low 32 bits (so we can pick uint32 safely).
op = simplified()->ChangeUint32ToTagged();
} else {
return TypeError(node, output_rep, output_type,
......
......@@ -249,7 +249,7 @@ class RepresentationChanger final {
MachineRepresentation output_rep,
Type* output_type);
Node* GetTaggedRepresentationFor(Node* node, MachineRepresentation output_rep,
Type* output_type);
Type* output_type, Truncation truncation);
Node* GetFloat32RepresentationFor(Node* node,
MachineRepresentation output_rep,
Type* output_type, Truncation truncation);
......
......@@ -929,9 +929,6 @@ class RepresentationSelector {
}
// Convert inputs to the output representation of this phi, pass the
// truncation truncation along.
if (output == MachineRepresentation::kTagged) {
truncation = Truncation::Any();
}
UseInfo input_use(output, truncation);
ProcessInput(node, 1, input_use);
ProcessInput(node, 2, input_use);
......@@ -956,9 +953,6 @@ class RepresentationSelector {
// Convert inputs to the output representation of this phi, pass the
// truncation along.
if (output == MachineRepresentation::kTagged) {
truncation = Truncation::Any();
}
UseInfo input_use(output, truncation);
for (int i = 0; i < node->InputCount(); i++) {
ProcessInput(node, i, i < values ? input_use : UseInfo::None());
......@@ -2446,10 +2440,6 @@ class RepresentationSelector {
// the sigma's type.
MachineRepresentation output =
GetOutputInfoForPhi(node, TypeOf(node->InputAt(0)), truncation);
if (output == MachineRepresentation::kTagged) {
truncation = Truncation::Any();
}
VisitUnop(node, UseInfo(output, truncation), output);
if (lower()) DeferReplacement(node, node->InputAt(0));
return;
......
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