This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Java patch: fix integer division folds



I recently noticed that gcj wasn't folding divisions or remainders
given two constant integer operands. 

parse.y says:

      if (code == RDIV_EXPR && TREE_CONSTANT (op1) && TREE_CONSTANT (op2)
          && JINTEGRAL_TYPE_P (op1) && JINTEGRAL_TYPE_P (op2))
        {
          TREE_TYPE (node) = prom_type;
          node = fold (node);
          if (TREE_CODE (node) != code)
            return node;
        }

This isn't working well right now because JINTEGRAL_TYPE_P isn't true
for INTEGER_CST nodes.  This patch fixes...

Tested libjava testsuite on x86 Linux with no regressions.  Ok?

AG



Tue Oct 23 22:01:14 2001  Anthony Green  <green@redhat.com>

        * parse.h (JINTEGRAL_TYPE_P): INTEGER_CST is a JINTEGRAL_TYPE_P.

Index: gcc/java/parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.77
diff -u -p -r1.77 parse.h
--- parse.h     2001/09/21 16:01:45     1.77
+++ parse.h     2001/10/24 05:02:02
@@ -171,7 +171,8 @@ extern tree stabilize_reference PARAMS (
 #define JFLOAT_TYPE_P(TYPE)      (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)
 #define JINTEGRAL_TYPE_P(TYPE)   ((TYPE)                                  \
                                  && (TREE_CODE ((TYPE)) == INTEGER_TYPE   \
-                                     || TREE_CODE ((TYPE)) == CHAR_TYPE))
+                                     || TREE_CODE ((TYPE)) == CHAR_TYPE   \
+                                      || TREE_CODE ((TYPE)) == INTEGER_CST))
 #define JNUMERIC_TYPE_P(TYPE)    ((TYPE)                               \
                                  && (JFLOAT_TYPE_P ((TYPE))            \
                                      || JINTEGRAL_TYPE_P ((TYPE))))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]