v8/test/mjsunit/regress/regress-crbug-891627.js
Benedikt Meurer 513a5bdd04 [turbofan] Fix Word32 (Signed32OrMinusZero) conversions that identify zeros.
When converting a Signed32\/MinusZero value from Word32 to Float64
representation or just passing it through as Word32 (with potential
type checks on it) we don't need to worry about -0 as long as the uses
identify 0 and -0.

Drive-by-fix: Fix the CheckChange() helper in the representation
changer test to pass Truncation::Any() by default.

Bug: chromium:891639, chromium:891612, chromium:891627, v8:8015, v8:8178
Change-Id: I06948ec0cdb8e778cb3678124ef927277a5f40ee
Reviewed-on: https://chromium-review.googlesource.com/c/1258902
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56369}
2018-10-04 09:13:18 +00:00

44 lines
1.2 KiB
JavaScript

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// We need a NumberModulus, so we make sure that we have a
// SpeculativeNumberModulus with Number feedback, and later
// on use it with known Number inputs (via the bitwise or),
// such that JSTypedLowering turns it into the NumberModulus.
function bar(x) { return x % 2; }
bar(0.1);
// Check that the Word32->Float64 conversion works properly.
(function() {
function foo(x) {
// The NumberEqual identifies 0 and -0.
return bar(x | -1) == 4294967295;
}
assertFalse(foo(1));
assertFalse(foo(0));
%OptimizeFunctionOnNextCall(foo);
assertFalse(foo(1));
assertFalse(foo(0));
})();
// Check that the Word32->Word32 conversion works properly.
(function() {
function makeFoo(y) {
return function foo(x) {
return bar(x | -1) == y;
}
}
makeFoo(0); // Defeat the function context specialization.
const foo = makeFoo(1);
assertFalse(foo(1));
assertFalse(foo(0));
%OptimizeFunctionOnNextCall(foo);
assertFalse(foo(1));
assertFalse(foo(0));
})();