v8/test/mjsunit/compiler/shift-shr.js
Jacob.Bramley@arm.com da48f1246c ARM64: Fix SHR logic error.
The `right == 0` checks only worked for `0 <= right < 32`. This patch
replaces the checks with simple tests for negative results.

The attached test can detect this error, but the test relies on a broken
flag (--noopt-safe-uint32-operations), so it is skipped for now. See
issue 3487 for details.

BUG=
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/487913005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23243 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-08-20 14:58:18 +00:00

27 lines
643 B
JavaScript

// Copyright 2014 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 --noopt-safe-uint32-operations
// Check the results of `left >>> right`. The result is always unsigned (and
// therefore positive).
function test_shr(left) {
var errors = 0;
for (var i = 1; i < 1024; i++) {
var temp = left >>> i;
if (temp < 0) {
errors++;
}
}
return errors;
}
assertEquals(0, test_shr(1));
%OptimizeFunctionOnNextCall(test_shr);
for (var i = 5; i >= -5; i--) {
assertEquals(0, test_shr(i));
}