Commit bd8a36a7 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Fold word32 representation changes for checked constants.

If we know that a constant can be represented as word32, then we don't
need to insert a checked conversion, but just change the constant
appropriately.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2100063002
Cr-Commit-Position: refs/heads/master@{#37273}
parent 8c8a9f18
...@@ -368,19 +368,30 @@ Node* RepresentationChanger::GetWord32RepresentationFor( ...@@ -368,19 +368,30 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type, Node* node, MachineRepresentation output_rep, Type* output_type,
Node* use_node, UseInfo use_info) { Node* use_node, UseInfo use_info) {
// Eagerly fold representation changes for constants. // Eagerly fold representation changes for constants.
// TODO(jarin) Properly fold constants in presence of type check. switch (node->opcode()) {
if (use_info.type_check() == TypeCheckKind::kNone) { case IrOpcode::kInt32Constant:
switch (node->opcode()) { return node; // No change necessary.
case IrOpcode::kInt32Constant: case IrOpcode::kFloat32Constant: {
return node; // No change necessary. float const fv = OpParameter<float>(node);
case IrOpcode::kFloat32Constant: if (use_info.type_check() == TypeCheckKind::kNone ||
return MakeTruncatedInt32Constant(OpParameter<float>(node)); (use_info.type_check() == TypeCheckKind::kSigned32 &&
case IrOpcode::kNumberConstant: IsInt32Double(fv))) {
case IrOpcode::kFloat64Constant: return MakeTruncatedInt32Constant(fv);
return MakeTruncatedInt32Constant(OpParameter<double>(node)); }
default: break;
break;
} }
case IrOpcode::kNumberConstant:
case IrOpcode::kFloat64Constant: {
double const fv = OpParameter<double>(node);
if (use_info.type_check() == TypeCheckKind::kNone ||
(use_info.type_check() == TypeCheckKind::kSigned32 &&
IsInt32Double(fv))) {
return MakeTruncatedInt32Constant(fv);
}
break;
}
default:
break;
} }
// Select the correct X -> Word32 operator. // Select the correct X -> Word32 operator.
......
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