This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for java/jcf-write.c handling of negative zero
- From: Mark Wielaard <mark at klomp dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: java-patches at gcc dot gnu dot org
- Date: 16 Apr 2002 22:00:59 +0200
- Subject: Patch for java/jcf-write.c handling of negative zero
Hi,
When writing java byte-code negative and positive zero are different.
So the following patch only writes const_0 when the value is not
negative.
2002-04-16 Mark Wielaard <mark@klomp.org>
* jcf-write.c (generate_bytecode_insns): Only write const_0 if not
negative zero.
Tested on i686-pc-linux-gnu and powerpc-unknown-linux-gnu.
It fixes the following new test case for libjava.lang.
2002-04-16 Mark Wielaard <mark@klomp.org>
* libjava.lang/negzero.java: New.
* libjava.lang/negzero.out: New.
It also fixes 7 failures in the Mauve testsuite which is why I would
also like this to go onto the 3.1 branch.
Ok to commit?
Cheers,
Mark
Index: gcc/java/jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.99.2.1
diff -u -u -r1.99.2.1 jcf-write.c
--- gcc/java/jcf-write.c 12 Mar 2002 10:33:57 -0000 1.99.2.1
+++ gcc/java/jcf-write.c 16 Apr 2002 19:59:21 -0000
@@ -25,6 +25,7 @@
#include "system.h"
#include "jcf.h"
#include "tree.h"
+#include "real.h"
#include "java-tree.h"
#include "obstack.h"
#undef AND
@@ -1536,7 +1537,7 @@
{
int prec = TYPE_PRECISION (type) >> 5;
RESERVE(1);
- if (real_zerop (exp))
+ if (real_zerop (exp) && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (exp)))
OP1 (prec == 1 ? OPCODE_fconst_0 : OPCODE_dconst_0);
else if (real_onep (exp))
OP1 (prec == 1 ? OPCODE_fconst_1 : OPCODE_dconst_1);
Index: libjava/testsuite/libjava.lang/negzero.java
===================================================================
RCS file: libjava/testsuite/libjava.lang/negzero.java
diff -N libjava/testsuite/libjava.lang/negzero.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.lang/negzero.java 16 Apr 2002 19:59:21 -0000
@@ -0,0 +1,8 @@
+public class negzero
+{
+ public static void main(String[] args)
+ {
+ System.out.println(-0.0);
+ System.out.println(-0.0f);
+ }
+}
Index: libjava/testsuite/libjava.lang/negzero.out
===================================================================
RCS file: libjava/testsuite/libjava.lang/negzero.out
diff -N libjava/testsuite/libjava.lang/negzero.out
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.lang/negzero.out 16 Apr 2002 19:59:21 -0000
@@ -0,0 +1,2 @@
+-0.0
+-0.0