v8/test/mjsunit/compiler/number-modulus.js
Sigurd Schneider 9b0e4e132f [turbofan] Make typed optimization more powerful
This CL moves optimization capabilities from typed lowering to typed
optimization. In particular, this allows retyping of Speculative to
number optimizations depending on their input types. This can save type
checks if we know that inputs are already in SafeIntegerRange and uses
are truncating to 32bit integers.

This change recovers the performance lost to 31bit Smis on
Octane/crypto on x64:
32bit nosmis           avg 30,984.84 stddev 180.52
31bit smis (w/o patch) avg 29,438.52 stddev 120.30  -4.99%
31bit smis             avg 31,274.52 stddev 176.26  +0.93%  +6.24%

Change-Id: I86d6e37305262336f4f7bd46aac0d2cbca11e8c1
Bug: v8:8344
Reviewed-on: https://chromium-review.googlesource.com/c/1323729
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57717}
2018-11-22 09:19:49 +00:00

27 lines
770 B
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 --opt --noalways-opt
// Test that NumberModulus passes kIdentifiesZero to the
// left hand side input when the result doesn't care about
// 0 vs -0, even when the inputs are outside Signed32.
(function() {
function foo(x) {
return (x * -2) % (2 ** 32) === 0;
}
assertFalse(foo(2));
assertFalse(foo(1));
%OptimizeFunctionOnNextCall(foo);
assertFalse(foo(2));
assertFalse(foo(1));
// Now `foo` should stay optimized even if `x * -2` would
// produce -0, aka when we pass a zero value for `x`.
assertTrue(foo(0));
assertOptimized(foo);
})();