summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSerguei Katkov <serguei.i.katkov@intel.com>2015-08-05 17:03:30 +0600
committerCalin Juravle <calin@google.com>2015-08-06 18:58:06 +0100
commitf2ea71cdb3ee4f5198bc0298aa8be1f9e945ee1c (patch)
tree0c133429186d7d9f796efa2d883941a8130246e0 /test
parentce4b1329ca903d6b98734a27a46b54bb9cfd6d5b (diff)
downloadart-f2ea71cdb3ee4f5198bc0298aa8be1f9e945ee1c.zip
art-f2ea71cdb3ee4f5198bc0298aa8be1f9e945ee1c.tar.gz
art-f2ea71cdb3ee4f5198bc0298aa8be1f9e945ee1c.tar.bz2
ART: Fix the simplifier for add/sub
Instruction simplifier for add/sub should not proceed with floats because that might cause the incorrect behavior with signed zero. Bug: 23001681 Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com> (cherry picked from commit 115b53f609e74672fa93eea1845bb17340d5112a) Change-Id: I9928724c4158b3961e32e376b9203fe01ba2e442
Diffstat (limited to 'test')
-rw-r--r--test/474-fp-sub-neg/expected.txt4
-rw-r--r--test/474-fp-sub-neg/info.txt6
-rw-r--r--test/474-fp-sub-neg/src/Main.java4
3 files changed, 14 insertions, 0 deletions
diff --git a/test/474-fp-sub-neg/expected.txt b/test/474-fp-sub-neg/expected.txt
index e6ffe0d..1c15abb 100644
--- a/test/474-fp-sub-neg/expected.txt
+++ b/test/474-fp-sub-neg/expected.txt
@@ -1,2 +1,6 @@
-0.0
+0.0
+0.0
-0.0
+0.0
+0.0
diff --git a/test/474-fp-sub-neg/info.txt b/test/474-fp-sub-neg/info.txt
index eced93f..82effdb 100644
--- a/test/474-fp-sub-neg/info.txt
+++ b/test/474-fp-sub-neg/info.txt
@@ -1,5 +1,11 @@
Regression check for optimizing simplify instruction pass.
+
A pair (sub, neg) should not be transforemd to (sub) for
fp calculation because we can lose the sign of zero for
the following expression:
- ( A - B ) != B - A ; if B == A
+
+Addition or subtraction with fp zero should not be eliminated
+because:
+ -0.0 + 0.0 = 0.0
+ -0.0 - -0.0 = 0.0
diff --git a/test/474-fp-sub-neg/src/Main.java b/test/474-fp-sub-neg/src/Main.java
index e6bce67..c190e8e 100644
--- a/test/474-fp-sub-neg/src/Main.java
+++ b/test/474-fp-sub-neg/src/Main.java
@@ -24,6 +24,8 @@ public class Main {
}
System.out.println(f);
+ System.out.println(f + 0f);
+ System.out.println(f - (-0f));
}
public static void doubleTest() {
@@ -35,6 +37,8 @@ public class Main {
}
System.out.println(d);
+ System.out.println(d + 0f);
+ System.out.println(d - (-0f));
}
public static void main(String[] args) {