diff options
author | Serban Constantinescu <serban.constantinescu@arm.com> | 2014-07-31 19:07:17 +0100 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-08-04 15:10:25 -0700 |
commit | 2eba1fa7e9e5f91e18ae3778d529520bd2c78d55 (patch) | |
tree | a75aae98e3329508a82e45c6bffea0777ec266b1 /test/082-inline-execute | |
parent | 7aaa8dbfbcde7f58564b42044892891559669838 (diff) | |
download | art-2eba1fa7e9e5f91e18ae3778d529520bd2c78d55.zip art-2eba1fa7e9e5f91e18ae3778d529520bd2c78d55.tar.gz art-2eba1fa7e9e5f91e18ae3778d529520bd2c78d55.tar.bz2 |
AArch64: Add inlining support for ceil(), floor(), rint(), round()
This patch adds inlining support for the following Math, StrictMath
methods in the ARM64 backend:
* double ceil(double)
* double floor(double)
* double rint(double)
* long round(double)
* int round(float)
Also some cleanup.
Change-Id: I9f5a2f4065b1313649f4b0c4380b8176703c3fe1
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Diffstat (limited to 'test/082-inline-execute')
-rw-r--r-- | test/082-inline-execute/src/Main.java | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java index 9ecc0a0..56972ff 100644 --- a/test/082-inline-execute/src/Main.java +++ b/test/082-inline-execute/src/Main.java @@ -34,6 +34,11 @@ public class Main { test_Math_max_F(); test_Math_min_D(); test_Math_max_D(); + test_Math_ceil(); + test_Math_floor(); + test_Math_rint(); + test_Math_round_D(); + test_Math_round_F(); test_Short_reverseBytes(); test_Integer_reverseBytes(); test_Long_reverseBytes(); @@ -49,6 +54,11 @@ public class Main { test_StrictMath_max_F(); test_StrictMath_min_D(); test_StrictMath_max_D(); + test_StrictMath_ceil(); + test_StrictMath_floor(); + test_StrictMath_rint(); + test_StrictMath_round_D(); + test_StrictMath_round_F(); test_String_charAt(); test_String_compareTo(); test_String_indexOf(); @@ -376,6 +386,104 @@ public class Main { Assert.assertEquals(Math.max(Double.MIN_VALUE, Double.MAX_VALUE), Double.MAX_VALUE); } + public static void test_Math_ceil() { + Assert.assertEquals(Math.ceil(+0.0), +0.0d, 0.0); + Assert.assertEquals(Math.ceil(-0.0), -0.0d, 0.0); + Assert.assertEquals(Math.ceil(-0.9), -0.0d, 0.0); + Assert.assertEquals(Math.ceil(-0.5), -0.0d, 0.0); + Assert.assertEquals(Math.ceil(0.0), -0.0d, 0.0); + Assert.assertEquals(Math.ceil(+2.0), +2.0d, 0.0); + Assert.assertEquals(Math.ceil(+2.1), +3.0d, 0.0); + Assert.assertEquals(Math.ceil(+2.5), +3.0d, 0.0); + Assert.assertEquals(Math.ceil(+2.9), +3.0d, 0.0); + Assert.assertEquals(Math.ceil(+3.0), +3.0d, 0.0); + Assert.assertEquals(Math.ceil(-2.0), -2.0d, 0.0); + Assert.assertEquals(Math.ceil(-2.1), -2.0d, 0.0); + Assert.assertEquals(Math.ceil(-2.5), -2.0d, 0.0); + Assert.assertEquals(Math.ceil(-2.9), -2.0d, 0.0); + Assert.assertEquals(Math.ceil(-3.0), -3.0d, 0.0); + Assert.assertEquals(Math.ceil(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(Math.ceil(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(Math.ceil(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_Math_floor() { + Assert.assertEquals(Math.floor(+0.0), +0.0d, 0.0); + Assert.assertEquals(Math.floor(-0.0), -0.0d, 0.0); + Assert.assertEquals(Math.floor(+2.0), +2.0d, 0.0); + Assert.assertEquals(Math.floor(+2.1), +2.0d, 0.0); + Assert.assertEquals(Math.floor(+2.5), +2.0d, 0.0); + Assert.assertEquals(Math.floor(+2.9), +2.0d, 0.0); + Assert.assertEquals(Math.floor(+3.0), +3.0d, 0.0); + Assert.assertEquals(Math.floor(-2.0), -2.0d, 0.0); + Assert.assertEquals(Math.floor(-2.1), -3.0d, 0.0); + Assert.assertEquals(Math.floor(-2.5), -3.0d, 0.0); + Assert.assertEquals(Math.floor(-2.9), -3.0d, 0.0); + Assert.assertEquals(Math.floor(-3.0), -3.0d, 0.0); + Assert.assertEquals(Math.floor(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(Math.floor(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(Math.floor(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_Math_rint() { + Assert.assertEquals(Math.rint(+0.0), +0.0d, 0.0); + Assert.assertEquals(Math.rint(-0.0), -0.0d, 0.0); + Assert.assertEquals(Math.rint(+2.0), +2.0d, 0.0); + Assert.assertEquals(Math.rint(+2.1), +2.0d, 0.0); + Assert.assertEquals(Math.rint(+2.5), +2.0d, 0.0); + Assert.assertEquals(Math.rint(+2.9), +3.0d, 0.0); + Assert.assertEquals(Math.rint(+3.0), +3.0d, 0.0); + Assert.assertEquals(Math.rint(-2.0), -2.0d, 0.0); + Assert.assertEquals(Math.rint(-2.1), -2.0d, 0.0); + Assert.assertEquals(Math.rint(-2.5), -2.0d, 0.0); + Assert.assertEquals(Math.rint(-2.9), -3.0d, 0.0); + Assert.assertEquals(Math.rint(-3.0), -3.0d, 0.0); + Assert.assertEquals(Math.rint(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(Math.rint(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(Math.rint(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_Math_round_D() { + Assert.assertEquals(Math.round(+0.0d), (long)+0.0); + Assert.assertEquals(Math.round(-0.0d), (long)+0.0); + Assert.assertEquals(Math.round(2.0d), 2l); + Assert.assertEquals(Math.round(2.1d), 2l); + Assert.assertEquals(Math.round(2.5d), 3l); + Assert.assertEquals(Math.round(2.9d), 3l); + Assert.assertEquals(Math.round(3.0d), 3l); + Assert.assertEquals(Math.round(-2.0d), -2l); + Assert.assertEquals(Math.round(-2.1d), -2l); + Assert.assertEquals(Math.round(-2.5d), -2l); + Assert.assertEquals(Math.round(-2.9d), -3l); + Assert.assertEquals(Math.round(-3.0d), -3l); + Assert.assertEquals(Math.round(0.49999999999999994d), 1l); + Assert.assertEquals(Math.round(Double.NaN), (long)+0.0d); + Assert.assertEquals(Math.round(Long.MAX_VALUE + 1.0d), Long.MAX_VALUE); + Assert.assertEquals(Math.round(Long.MIN_VALUE - 1.0d), Long.MIN_VALUE); + Assert.assertEquals(Math.round(Double.POSITIVE_INFINITY), Long.MAX_VALUE); + Assert.assertEquals(Math.round(Double.NEGATIVE_INFINITY), Long.MIN_VALUE); + } + + public static void test_Math_round_F() { + Assert.assertEquals(Math.round(+0.0f), (int)+0.0); + Assert.assertEquals(Math.round(-0.0f), (int)+0.0); + Assert.assertEquals(Math.round(2.0f), 2); + Assert.assertEquals(Math.round(2.1f), 2); + Assert.assertEquals(Math.round(2.5f), 3); + Assert.assertEquals(Math.round(2.9f), 3); + Assert.assertEquals(Math.round(3.0f), 3); + Assert.assertEquals(Math.round(-2.0f), -2); + Assert.assertEquals(Math.round(-2.1f), -2); + Assert.assertEquals(Math.round(-2.5f), -2); + Assert.assertEquals(Math.round(-2.9f), -3); + Assert.assertEquals(Math.round(-3.0f), -3); + Assert.assertEquals(Math.round(Float.NaN), (int)+0.0f); + Assert.assertEquals(Math.round(Integer.MAX_VALUE + 1.0f), Integer.MAX_VALUE); + Assert.assertEquals(Math.round(Integer.MIN_VALUE - 1.0f), Integer.MIN_VALUE); + Assert.assertEquals(Math.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE); + Assert.assertEquals(Math.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE); + } + public static void test_StrictMath_abs_I() { Assert.assertEquals(StrictMath.abs(0), 0); Assert.assertEquals(StrictMath.abs(123), 123); @@ -487,6 +595,104 @@ public class Main { Assert.assertEquals(StrictMath.max(Double.MIN_VALUE, Double.MAX_VALUE), Double.MAX_VALUE); } + public static void test_StrictMath_ceil() { + Assert.assertEquals(StrictMath.ceil(+0.0), +0.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-0.0), -0.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-0.9), -0.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-0.5), -0.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(0.0), -0.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(+2.0), +2.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(+2.1), +3.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(+2.5), +3.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(+2.9), +3.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(+3.0), +3.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-2.0), -2.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-2.1), -2.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-2.5), -2.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-2.9), -2.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(-3.0), -3.0d, 0.0); + Assert.assertEquals(StrictMath.ceil(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(StrictMath.ceil(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(StrictMath.ceil(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_StrictMath_floor() { + Assert.assertEquals(StrictMath.floor(+0.0), +0.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-0.0), -0.0d, 0.0); + Assert.assertEquals(StrictMath.floor(+2.0), +2.0d, 0.0); + Assert.assertEquals(StrictMath.floor(+2.1), +2.0d, 0.0); + Assert.assertEquals(StrictMath.floor(+2.5), +2.0d, 0.0); + Assert.assertEquals(StrictMath.floor(+2.9), +2.0d, 0.0); + Assert.assertEquals(StrictMath.floor(+3.0), +3.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-2.0), -2.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-2.1), -3.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-2.5), -3.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-2.9), -3.0d, 0.0); + Assert.assertEquals(StrictMath.floor(-3.0), -3.0d, 0.0); + Assert.assertEquals(StrictMath.floor(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(StrictMath.floor(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(StrictMath.floor(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_StrictMath_rint() { + Assert.assertEquals(StrictMath.rint(+0.0), +0.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-0.0), -0.0d, 0.0); + Assert.assertEquals(StrictMath.rint(+2.0), +2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(+2.1), +2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(+2.5), +2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(+2.9), +3.0d, 0.0); + Assert.assertEquals(StrictMath.rint(+3.0), +3.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-2.0), -2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-2.1), -2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-2.5), -2.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-2.9), -3.0d, 0.0); + Assert.assertEquals(StrictMath.rint(-3.0), -3.0d, 0.0); + Assert.assertEquals(StrictMath.rint(Double.NaN), Double.NaN, 0.0); + Assert.assertEquals(StrictMath.rint(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY, 0.0); + Assert.assertEquals(StrictMath.rint(Double.NEGATIVE_INFINITY), Double.NEGATIVE_INFINITY, 0.0); + } + + public static void test_StrictMath_round_D() { + Assert.assertEquals(StrictMath.round(+0.0d), (long)+0.0); + Assert.assertEquals(StrictMath.round(-0.0d), (long)+0.0); + Assert.assertEquals(StrictMath.round(2.0d), 2l); + Assert.assertEquals(StrictMath.round(2.1d), 2l); + Assert.assertEquals(StrictMath.round(2.5d), 3l); + Assert.assertEquals(StrictMath.round(2.9d), 3l); + Assert.assertEquals(StrictMath.round(3.0d), 3l); + Assert.assertEquals(StrictMath.round(-2.0d), -2l); + Assert.assertEquals(StrictMath.round(-2.1d), -2l); + Assert.assertEquals(StrictMath.round(-2.5d), -2l); + Assert.assertEquals(StrictMath.round(-2.9d), -3l); + Assert.assertEquals(StrictMath.round(-3.0d), -3l); + Assert.assertEquals(StrictMath.round(0.49999999999999994d), 1l); + Assert.assertEquals(StrictMath.round(Double.NaN), (long)+0.0d); + Assert.assertEquals(StrictMath.round(Long.MAX_VALUE + 1.0d), Long.MAX_VALUE); + Assert.assertEquals(StrictMath.round(Long.MIN_VALUE - 1.0d), Long.MIN_VALUE); + Assert.assertEquals(StrictMath.round(Double.POSITIVE_INFINITY), Long.MAX_VALUE); + Assert.assertEquals(StrictMath.round(Double.NEGATIVE_INFINITY), Long.MIN_VALUE); + } + + public static void test_StrictMath_round_F() { + Assert.assertEquals(StrictMath.round(+0.0f), (int)+0.0); + Assert.assertEquals(StrictMath.round(-0.0f), (int)+0.0); + Assert.assertEquals(StrictMath.round(2.0f), 2); + Assert.assertEquals(StrictMath.round(2.1f), 2); + Assert.assertEquals(StrictMath.round(2.5f), 3); + Assert.assertEquals(StrictMath.round(2.9f), 3); + Assert.assertEquals(StrictMath.round(3.0f), 3); + Assert.assertEquals(StrictMath.round(-2.0f), -2); + Assert.assertEquals(StrictMath.round(-2.1f), -2); + Assert.assertEquals(StrictMath.round(-2.5f), -2); + Assert.assertEquals(StrictMath.round(-2.9f), -3); + Assert.assertEquals(StrictMath.round(-3.0f), -3); + Assert.assertEquals(StrictMath.round(Float.NaN), (int)+0.0f); + Assert.assertEquals(StrictMath.round(Integer.MAX_VALUE + 1.0f), Integer.MAX_VALUE); + Assert.assertEquals(StrictMath.round(Integer.MIN_VALUE - 1.0f), Integer.MIN_VALUE); + Assert.assertEquals(StrictMath.round(Float.POSITIVE_INFINITY), Integer.MAX_VALUE); + Assert.assertEquals(StrictMath.round(Float.NEGATIVE_INFINITY), Integer.MIN_VALUE); + } + public static void test_Float_floatToRawIntBits() { Assert.assertEquals(Float.floatToRawIntBits(-1.0f), 0xbf800000); Assert.assertEquals(Float.floatToRawIntBits(0.0f), 0); |