Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Unified Diff: tests/language/vm/regress_29137_vm_test.dart

Issue 2793003002: VM: Fix incorrect canonicalization rule for `UnboxedIntConverterInstr`. (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/vm/regress_29137_vm_test.dart
diff --git a/tests/language/vm/regress_29137_vm_test.dart b/tests/language/vm/regress_29137_vm_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e20545b8758d5e4cddef89fc8ea4b9693e75c57f
--- /dev/null
+++ b/tests/language/vm/regress_29137_vm_test.dart
@@ -0,0 +1,36 @@
+// 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 convertion is
+// truncating and is erasing the high part of the mint value.
+//
+// VMOptions=--optimization-counter-threshold=5 --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 emittion of BinaryMintOp instructions for shifts.
+ const value = 0xF0F00000;
+ const rotated = 0xF00000F0;
+ Expect.equals(rotated, rot8(value));
+ for (var i = 0; i < 10; i++) {
+ Expect.equals(rotated, rot8(value));
+ }
+}
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698