jcf-write.c (find_constant_index): Canonicalize NaNs when generating bytecode.
authorAndrew Haley <aph@redhat.com>
Mon, 16 Aug 2004 13:03:51 +0000 (13:03 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Mon, 16 Aug 2004 13:03:51 +0000 (13:03 +0000)
2004-08-16  Andrew Haley  <aph@redhat.com>

        * jcf-write.c (find_constant_index): Canonicalize NaNs when
        generating bytecode.

From-SVN: r86053

gcc/java/ChangeLog
gcc/java/jcf-write.c

index 4e0dc7e3de388ca5c5b4e57f8f547b20411345fd..761c886f728a9cf244a3cb3536ae03a1b3bb345b 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-16  Andrew Haley  <aph@redhat.com>
+
+       * jcf-write.c (find_constant_index): Canonicalize NaNs when
+       generating bytecode.
+
 2004-08-16  Elliot Lee <sopwith@redhat.com>
 
        PR java/9677
index d775a816ff2836cffb22d9290a92e4029cffcdbd..7b5bdcce7f1663bff91a22b95de0431fd0b54c67 100644 (file)
@@ -798,6 +798,19 @@ find_constant_index (tree value, struct jcf_partial *state)
     {
       long words[2];
 
+      /* IEEE NaN can have many values, but the Java VM spec defines a
+        canonical NaN.  */      
+      if (flag_emit_class_files
+         && REAL_VALUE_ISNAN (TREE_REAL_CST (value)))
+       {
+         if (TYPE_PRECISION (TREE_TYPE (value)) == 32)
+           return find_constant1 (&state->cpool, CONSTANT_Float,
+                                  0x7fc00000);
+         else
+           return find_constant2 (&state->cpool, CONSTANT_Double,
+                                  0x7ff80000, 0x00000000);
+       }           
+      
       real_to_target (words, &TREE_REAL_CST (value),
                      TYPE_MODE (TREE_TYPE (value)));
       words[0] &= 0xffffffff;