Commit 4d4949c5 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbofan] Generate Float constants for certain checked conversions

This change ensures that we do not try to check the conversion of a floating
point constant, but insert the floating point constant instead.

Change-Id: I1c65e3a69acaea2ff805ba10317f64c0ac0ba098
Reviewed-on: https://chromium-review.googlesource.com/c/1340257Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57630}
parent 7be38851
...@@ -605,18 +605,17 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( ...@@ -605,18 +605,17 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
Node* RepresentationChanger::GetFloat64RepresentationFor( Node* RepresentationChanger::GetFloat64RepresentationFor(
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. NumberMatcher m(node);
if ((use_info.type_check() == TypeCheckKind::kNone)) { if (m.HasValue()) {
// TODO(jarin) Handle checked constant conversions. switch (use_info.type_check()) {
switch (node->opcode()) { case TypeCheckKind::kNone:
case IrOpcode::kNumberConstant: case TypeCheckKind::kNumber:
return jsgraph()->Float64Constant(OpParameter<double>(node->op())); case TypeCheckKind::kNumberOrOddball:
case IrOpcode::kInt32Constant: return jsgraph()->Float64Constant(m.Value());
case IrOpcode::kFloat64Constant: case TypeCheckKind::kHeapObject:
case IrOpcode::kFloat32Constant: case TypeCheckKind::kSigned32:
UNREACHABLE(); case TypeCheckKind::kSigned64:
break; case TypeCheckKind::kSignedSmall:
default:
break; break;
} }
} }
......
...@@ -204,6 +204,15 @@ TEST(ToFloat64_constant) { ...@@ -204,6 +204,15 @@ TEST(ToFloat64_constant) {
UseInfo(MachineRepresentation::kFloat64, Truncation::None())); UseInfo(MachineRepresentation::kFloat64, Truncation::None()));
r.CheckFloat64Constant(c, i); r.CheckFloat64Constant(c, i);
} }
{
Node* n = r.jsgraph()->Constant(0);
Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor(
n, MachineRepresentation::kWord64, Type::Range(0, 0, r.zone()), use,
UseInfo(MachineRepresentation::kFloat64, Truncation::None()));
r.CheckFloat64Constant(c, 0);
}
} }
......
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