dart-sdk/tests/language/vm/regress_29137_vm_test.dart
Alexander Markov 24b8399086 [tests] Avoid small --optimization-counter-threshold in tests
Small --optimization-counter-threshold makes tests very slow,
especially on architectures where kernel service runs from
kernel and not from app-jit snapshot.

TEST=change in tests, *-ia32 bots
Fixes https://github.com/dart-lang/sdk/issues/48627

Change-Id: I63e7e201ef9a0e4f645016c39a5be1819b61822d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263421
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-10-10 21:04:18 +00:00

37 lines
1.2 KiB
Dart

// Copyright (c) 2017, 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.
//
// Check that optimizer correctly handles (x << y) & MASK_32 pattern on 32-bit
// platforms: given the pattern
//
// v1 <- UnboxedIntConverter([tr] mint->uint32, v0)
// v2 <- UnboxedIntConverter(uint32->mint, v1)
//
// optimizer must *not* replace v2 with v0 because the first conversion is
// truncating and is erasing the high part of the mint value.
//
// VMOptions=--optimization-counter-threshold=90 --no-background-compilation
import "package:expect/expect.dart";
const _MASK_32 = 0xffffffff;
int _rotl32(int val, int shift) {
final mod_shift = shift & 31;
return ((val << mod_shift) & _MASK_32) |
((val & _MASK_32) >> (32 - mod_shift));
}
rot8(v) => _rotl32(v, 8);
main() {
// Note: value is selected in such a way that (value << 8) is not a smi - this
// triggers emission of BinaryMintOp instructions for shifts.
const value = 0xF0F00000;
const rotated = 0xF00000F0;
Expect.equals(rotated, rot8(value));
for (var i = 0; i < 100; i++) {
Expect.equals(rotated, rot8(value));
}
}