This is the mail archive of the gcc@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]

Re: Merged ARM-Thumb branch...


Philip Blundell wrote:
> 
> >-  if (CONSTANT_P (operands[1]) && flag_pic)
> >+  if (CONSTANT_P (operands[1]) || symbol_mentioned_p (operands[1])
> >+       || label_mentioned_p (operands[1]) && flag_pic)
> 
> This patch was originally written by Pat, as far as I know.  It's been in my
> tree for years.

Probably time we integrated it then :).  I'll generate a changelog and submit
it.

 
> >Fri Jul 16 10:29:48 1999  Philip Blundell  <pb@futuretv.com>
> >        * function.c (rtx_equal_for_addressof_p): New function.
> >        (purge_addressof_1): Use it instead of rtx_equal_p.
>
> As far as I know, this bug is still present, but I'm not at all convinced that
> my patch is the right answer.

Any comments would be appreciated then.

> The patch you posted only includes the first of these changes, which is not
> much use in isolation. :-)

Oops your right.  Here's the complete patch.

diff -uNpr gcc-2.95.2.orig/gcc/function.c gcc-2.95.2/gcc/function.c
--- gcc-2.95.2.orig/gcc/function.c      Tue Sep  7 03:34:04 1999
+++ gcc-2.95.2/gcc/function.c   Sat Feb  5 07:56:05 2000
@@ -3043,6 +3043,105 @@ static rtx purge_bitfield_addressof_repl
    extracted by usage MEM with narrower mode. */
 static rtx purge_addressof_replacements;
 
+/* Return 1 if X and Y are identical-looking rtx's.
+   This is the Lisp function EQUAL for rtx arguments.  */
+
+int
+rtx_equal_for_addressof_p (x, y)
+     rtx x, y;
+{
+  register int i;
+  register int j;
+  register enum rtx_code code;
+  register char *fmt;
+
+  if (x == y)
+    return 1;
+  if (x == 0 || y == 0)
+    return 0;
+
+  code = GET_CODE (x);
+  /* Rtx's of different codes cannot be equal.  */
+  if (code != GET_CODE (y))
+    return 0;
+
+  /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
+     (REG:SI x) and (REG:HI x) are NOT equivalent. 
+     But (MEM:SI x) and (MEM:HI x) are equivalent for our purposes.  */
+
+  if (code != MEM && (GET_MODE (x) != GET_MODE (y)))
+    return 0;
+
+  /* REG, LABEL_REF, and SYMBOL_REF can be compared nonrecursively.  */
+
+  if (code == REG)
+    return REGNO (x) == REGNO (y);
+  else if (code == LABEL_REF)
+    return XEXP (x, 0) == XEXP (y, 0);
+  else if (code == SYMBOL_REF)
+    return XSTR (x, 0) == XSTR (y, 0);
+  else if (code == SCRATCH || code == CONST_DOUBLE)
+    return 0;
+
+  /* Compare the elements.  If any pair of corresponding elements
+     fail to match, return 0 for the whole things.  */
+
+  fmt = GET_RTX_FORMAT (code);
+  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+    {
+      switch (fmt[i])
+       {
+       case 'w':
+         if (XWINT (x, i) != XWINT (y, i))
+           return 0;
+         break;
+
+       case 'n':
+       case 'i':
+         if (XINT (x, i) != XINT (y, i))
+           return 0;
+         break;
+
+       case 'V':
+       case 'E':
+         /* Two vectors must have the same length.  */
+         if (XVECLEN (x, i) != XVECLEN (y, i))
+           return 0;
+
+         /* And the corresponding elements must match.  */
+         for (j = 0; j < XVECLEN (x, i); j++)
+           if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
+             return 0;
+         break;
+
+       case 'e':
+         if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
+           return 0;
+         break;
+
+       case 'S':
+       case 's':
+         if (strcmp (XSTR (x, i), XSTR (y, i)))
+           return 0;
+         break;
+
+       case 'u':
+         /* These are just backpointers, so they don't matter.  */
+         break;
+
+       case '0':
+         break;
+
+         /* It is believed that rtx's at this level will never
+            contain anything but integers and other rtx's,
+            except for within LABEL_REFs and SYMBOL_REFs.  */
+       default:
+         abort ();
+       }
+    }
+  return 1;
+}
+
 /* Helper function for purge_addressof.  See if the rtx expression at *LOC
    in INSN needs to be changed.  If FORCE, always put any ADDRESSOFs into
    the stack.  */
@@ -3123,7 +3222,7 @@ purge_addressof_1 (loc, insn, force, sto
              for (tem = purge_bitfield_addressof_replacements;
                   tem != NULL_RTX;
                   tem = XEXP (XEXP (tem, 1), 1))
-               if (rtx_equal_p (x, XEXP (tem, 0)))
+               if (rtx_equal_for_addressof_p (x, XEXP (tem, 0)))
                  {
                    *loc = XEXP (XEXP (tem, 1), 0);
                    return;
@@ -3133,7 +3232,7 @@ purge_addressof_1 (loc, insn, force, sto
              for (tem = purge_addressof_replacements;
                   tem != NULL_RTX;
                   tem = XEXP (XEXP (tem, 1), 1))
-               if (rtx_equal_p (XEXP (x, 0), XEXP (tem, 0)))
+               if (rtx_equal_for_addressof_p (XEXP (x, 0), XEXP (tem, 0)))
                  {
                    rtx z = XEXP (XEXP (tem, 1), 0);

-- 
Scott Bambrough - Software Engineer
REBEL.COM    http://www.rebel.com
NetWinder    http://www.netwinder.org

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