Files
sdk/tests/language_2/vm/bitnot_int_test.dart
T
Samir Jindel 927b0cb9ed [vm/aot] Support optimization of modulo against a power-of-two.
Improves MD5 performance on ARM32 by 15%, from 1.25s to 1.05s.

Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
Change-Id: Ia7a0614da662a80db051362fff7a4acacbc2455f
Reviewed-on: https://dart-review.googlesource.com/c/88723
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-01-09 16:26:35 +00:00

46 lines
1.1 KiB
Dart

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--no_background_compilation --optimization_counter_threshold=10
import "package:expect/expect.dart";
// Tests for long bit-not under 64-bit arithmetic wrap-around semantics.
final int maxInt32 = 2147483647;
final int minInt32 = -2147483648;
final int maxInt64 = 0x7fffffffffffffff;
final int minInt64 = 0x8000000000000000;
int bitnot(int x) {
return ~x;
}
doConstant() {
Expect.equals(0, bitnot(-1));
Expect.equals(-1, bitnot(0));
Expect.equals(-2, bitnot(1));
Expect.equals(minInt32, bitnot(maxInt32));
Expect.equals(maxInt32, bitnot(minInt32));
Expect.equals(minInt64, bitnot(maxInt64));
Expect.equals(maxInt64, bitnot(minInt64)); // sic!
}
doVar() {
int d = 0;
for (int i = -88; i < 10; i++) {
d += bitnot(i);
}
Expect.equals(3773, d);
}
main() {
// Repeat tests to enter JIT (when applicable).
for (int i = 0; i < 20; i++) {
doConstant();
doVar();
}
}