OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // | |
5 // Check that optimizer correctly handles (x << y) & MASK_32 pattern on 32-bit | |
6 // platforms: given the pattern | |
7 // | |
8 // v1 <- UnboxedIntConverter([tr] mint->uint32, v0) | |
9 // v2 <- UnboxedIntConverter(uint32->mint, v1) | |
10 // | |
11 // optimizer must *not* replace v2 with v0 because the first convertion is | |
12 // truncating and is erasing the high part of the mint value. | |
13 // | |
14 // VMOptions=--optimization-counter-threshold=5 --no-background-compilation | |
15 | |
16 import "package:expect/expect.dart"; | |
17 | |
18 const _MASK_32 = 0xffffffff; | |
19 int _rotl32(int val, int shift) { | |
20 var mod_shift = shift & 31; | |
kustermann
2017/04/03 15:31:48
final :)
| |
21 return ((val << mod_shift) & _MASK_32) | | |
22 ((val & _MASK_32) >> (32 - mod_shift)); | |
23 } | |
24 | |
25 rot8(v) => _rotl32(v, 8); | |
26 | |
27 main() { | |
28 // Note: value is selected in such a way that (value << 8) is not a smi - this | |
29 // triggers emittion of BinaryMintOp instructions for shifts. | |
30 const value = 0xF0F00000; | |
31 const rotated = 0xF00000F0; | |
32 Expect.equals(rotated, rot8(value)); | |
33 for (var i = 0; i < 10; i++) { | |
34 Expect.equals(rotated, rot8(value)); | |
35 } | |
36 } | |
OLD | NEW |