summaryrefslogtreecommitdiffstats
path: root/jack-tests
diff options
context:
space:
mode:
authormikaelpeltier <mikaelpeltier@google.com>2015-05-19 16:02:15 +0200
committerMikael Peltier <mikaelpeltier@google.com>2015-05-21 11:06:19 +0000
commit2a9ba9420757bba501858d56eada436716fb0d41 (patch)
treef29d3948017e048b999ceda19270ec9d474ec06b /jack-tests
parente09b67627256f40adc3b48372a4ad91e73c5b67f (diff)
downloadtoolchain_jack-2a9ba9420757bba501858d56eada436716fb0d41.tar.gz
toolchain_jack-2a9ba9420757bba501858d56eada436716fb0d41.tar.bz2
toolchain_jack-2a9ba9420757bba501858d56eada436716fb0d41.zip
NotSimplifier must take into account floating types
- cmpl-x and cmpg-x do not return the same value for Nan operands. Consequently !(a>b) can not be replace by a<=b when using floating types otherwise the condition will not be evaluated correctly at runtime. Bug: 21212402 Change-Id: Idfd37459b0013e1d0fba274bbc0f9acc103bb605 (cherry picked from commit 0635c13e2a4581dec9e3b3e78c4b6dcd8327a2d7)
Diffstat (limited to 'jack-tests')
-rw-r--r--jack-tests/tests/com/android/jack/comparison/ComparisonTests.java1
-rw-r--r--jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java12
-rw-r--r--jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java86
-rw-r--r--jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java44
4 files changed, 142 insertions, 1 deletions
diff --git a/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java b/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java
index 6a85530e..978e8049 100644
--- a/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java
+++ b/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java
@@ -23,7 +23,6 @@ import com.android.jack.test.runtime.RuntimeTestInfo;
import com.android.jack.test.toolchain.AbstractTestTools;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java
index 0962ae2f..9c55e5e9 100644
--- a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java
+++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java
@@ -32,18 +32,30 @@ public class NotsimplifierTests extends RuntimeTest {
AbstractTestTools.getTestRootDir("com.android.jack.optimizations.notsimplifier.test001"),
"com.android.jack.optimizations.notsimplifier.test001.dx.Tests");
+ private RuntimeTestInfo TEST002 = new RuntimeTestInfo(
+ AbstractTestTools.getTestRootDir("com.android.jack.optimizations.notsimplifier.test002"),
+ "com.android.jack.optimizations.notsimplifier.test002.dx.Tests");
+
@BeforeClass
public static void setUpClass() {
NotsimplifierTests.class.getClassLoader().setDefaultAssertionStatus(true);
}
+
@Test
@Category(RuntimeRegressionTest.class)
public void test001() throws Exception {
new RuntimeTestHelper(TEST001).compileAndRunTest();
}
+ @Test
+ @Category(RuntimeRegressionTest.class)
+ public void test002() throws Exception {
+ new RuntimeTestHelper(TEST002).compileAndRunTest();
+ }
+
@Override
protected void fillRtTestInfos() {
rtTestInfos.add(TEST001);
+ rtTestInfos.add(TEST002);
}
}
diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java
new file mode 100644
index 00000000..f63b42f1
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.jack.optimizations.notsimplifier.test002.dx;
+
+import com.android.jack.optimizations.notsimplifier.test002.jack.NotSimplifier;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Tests about '!' simplifier optimization using comparison with bounds values or not of types.
+ */
+public class Tests {
+
+ @Test
+ public void test1() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Double.NaN));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0.0d));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5.0d));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Double.MIN_VALUE));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Double.NEGATIVE_INFINITY));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Double.POSITIVE_INFINITY));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Double.MAX_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(5.0d));
+ }
+
+ @Test
+ public void test2() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Float.NaN));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0.0f));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5.0f));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Float.MIN_VALUE));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Float.NEGATIVE_INFINITY));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Float.POSITIVE_INFINITY));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Float.MAX_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(5.0f));
+ }
+
+ @Test
+ public void test3() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0l));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5l));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Long.MIN_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Long.MAX_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(1l));
+ }
+
+ @Test
+ public void test4() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Integer.MIN_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Integer.MAX_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(1));
+ }
+
+ @Test
+ public void test5() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0((byte) 0));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0((byte) -5));
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Byte.MIN_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Byte.MAX_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0((byte) 1));
+ }
+
+ @Test
+ public void test6() {
+ Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Character.MIN_VALUE));
+ Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Character.MAX_VALUE));
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java
new file mode 100644
index 00000000..bdd78444
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.jack.optimizations.notsimplifier.test002.jack;
+
+public class NotSimplifier {
+
+ public static boolean smallerOrEqualTo0(double n) {
+ return !(n > 0);
+ }
+
+ public static boolean smallerOrEqualTo0(float n) {
+ return !(n > 0);
+ }
+
+ public static boolean smallerOrEqualTo0(long n) {
+ return !(n > 0);
+ }
+
+ public static boolean smallerOrEqualTo0(int n) {
+ return !(n > 0);
+ }
+
+ public static boolean smallerOrEqualTo0(byte n) {
+ return !(n > 0);
+ }
+
+ public static boolean smallerOrEqualTo0(char n) {
+ return !(n > 0);
+ }
+}