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(
Node* RepresentationChanger::GetFloat64RepresentationFor(
Node* node, MachineRepresentation output_rep, Type output_type,
Node* use_node, UseInfo use_info) {
// Eagerly fold representation changes for constants.
if ((use_info.type_check() == TypeCheckKind::kNone)) {
// TODO(jarin) Handle checked constant conversions.
switch (node->opcode()) {
case IrOpcode::kNumberConstant:
return jsgraph()->Float64Constant(OpParameter<double>(node->op()));
case IrOpcode::kInt32Constant:
case IrOpcode::kFloat64Constant:
case IrOpcode::kFloat32Constant:
UNREACHABLE();
break;
default:
NumberMatcher m(node);
if (m.HasValue()) {
switch (use_info.type_check()) {
case TypeCheckKind::kNone:
case TypeCheckKind::kNumber:
case TypeCheckKind::kNumberOrOddball:
return jsgraph()->Float64Constant(m.Value());
case TypeCheckKind::kHeapObject:
case TypeCheckKind::kSigned32:
case TypeCheckKind::kSigned64:
case TypeCheckKind::kSignedSmall:
break;
}
}
......
......@@ -204,6 +204,15 @@ TEST(ToFloat64_constant) {
UseInfo(MachineRepresentation::kFloat64, Truncation::None()));
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