Skip to content

Commit a8cb521

Browse files
GeorgNeisCommit Bot
authored andcommitted
[turbofan] Allow converting word64 to float32 if value is safe integer.
Bug: v8:895691 Change-Id: Ic92cb250555d097b01f894b4b7b9ae5b2eea6668 Reviewed-on: https://chromium-review.googlesource.com/c/1282990 Commit-Queue: Georg Neis <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]> Cr-Commit-Position: refs/heads/master@{#56691}
1 parent f56195f commit a8cb521

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/compiler/representation-change.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
586586
} else if (output_rep == MachineRepresentation::kFloat64) {
587587
op = machine()->TruncateFloat64ToFloat32();
588588
} else if (output_rep == MachineRepresentation::kWord64) {
589-
if (output_type.Is(Type::Signed32())) {
589+
if (output_type.Is(cache_.kSafeInteger)) {
590590
// int64 -> float64 -> float32
591591
op = machine()->ChangeInt64ToFloat64();
592592
node = jsgraph()->graph()->NewNode(op, node);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
const n = 2**32;
8+
const x = new Float32Array();
9+
10+
function f() {
11+
for (var i = 96; i < 100; i += 4) {
12+
x[i] = i + n;
13+
}
14+
}
15+
16+
f();
17+
%OptimizeFunctionOnNextCall(f);
18+
f();

0 commit comments

Comments
 (0)