diff options
author | Calin Juravle <calin@google.com> | 2014-10-07 20:23:36 +0100 |
---|---|---|
committer | Calin Juravle <calin@google.com> | 2014-10-17 11:46:45 +0100 |
commit | 34bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2 (patch) | |
tree | e8ed8e40c5f7896a9ac01bf7dcc2e56f40cfc804 /test | |
parent | 7f758228f7904d2f65f06bfbd2b8ecbb8e8c6a9d (diff) | |
download | art-34bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2.tar.gz art-34bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2.tar.bz2 art-34bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2.zip |
Add multiplication for integral types
This also fixes an issue where we could allocate a pair register even if
one of its parts was already blocked.
Change-Id: I4869175933409add2a56f1ccfb369c3d3dd3cb01
Diffstat (limited to 'test')
-rw-r--r-- | test/411-optimizing-arith/expected.txt | 0 | ||||
-rw-r--r-- | test/411-optimizing-arith/info.txt | 1 | ||||
-rw-r--r-- | test/411-optimizing-arith/src/Main.java | 64 |
3 files changed, 65 insertions, 0 deletions
diff --git a/test/411-optimizing-arith/expected.txt b/test/411-optimizing-arith/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/411-optimizing-arith/expected.txt diff --git a/test/411-optimizing-arith/info.txt b/test/411-optimizing-arith/info.txt new file mode 100644 index 0000000000..10155512f0 --- /dev/null +++ b/test/411-optimizing-arith/info.txt @@ -0,0 +1 @@ +Tests for basic arithmethic operations. diff --git a/test/411-optimizing-arith/src/Main.java b/test/411-optimizing-arith/src/Main.java new file mode 100644 index 0000000000..74c47a606c --- /dev/null +++ b/test/411-optimizing-arith/src/Main.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Note that $opt$ is a marker for the optimizing compiler to ensure +// it does compile the method. + +public class Main { + + public static void expectEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void expectEquals(long expected, long result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void main(String[] args) { + mul(); + } + + public static void mul() { + expectEquals(15, $opt$Mul(5, 3)); + expectEquals(0, $opt$Mul(0, 3)); + expectEquals(0, $opt$Mul(3, 0)); + expectEquals(-3, $opt$Mul(1, -3)); + expectEquals(36, $opt$Mul(-12, -3)); + expectEquals(33, $opt$Mul(1, 3) * 11); + expectEquals(671088645, $opt$Mul(134217729, 5)); // (2^27 + 1) * 5 + + expectEquals(15L, $opt$Mul(5L, 3L)); + expectEquals(0L, $opt$Mul(0L, 3L)); + expectEquals(0L, $opt$Mul(3L, 0L)); + expectEquals(-3L, $opt$Mul(1L, -3L)); + expectEquals(36L, $opt$Mul(-12L, -3L)); + expectEquals(33L, $opt$Mul(1L, 3L) * 11); + expectEquals(240518168583L, $opt$Mul(34359738369L, 7L)); // (2^35 + 1) * 7 + } + + static int $opt$Mul(int a, int b) { + return a * b; + } + + static long $opt$Mul(long a, long b) { + return a * b; + } + +} |