Extra arg for rtx_varies_p
authorBernd Schmidt <bernds@redhat.com>
Mon, 1 Jan 2001 17:20:09 +0000 (17:20 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Mon, 1 Jan 2001 17:20:09 +0000 (17:20 +0000)
From-SVN: r38590

gcc/ChangeLog
gcc/alias.c
gcc/config/a29k/a29k.h
gcc/cse.c
gcc/local-alloc.c
gcc/reload.c
gcc/rtl.h
gcc/rtlanal.c

index d28c7eef98e94b7da90990b0ab4e7dbf3cc6cd59..d3d1c0984652671db55bafdeafb2c5157f5e50ca 100644 (file)
@@ -1,3 +1,16 @@
+2001-01-01  Bernd Schmidt  <bernds@redhat.com>
+
+       * alias.c (fixed_scalar_and_varying_struct): Adjust prototype of
+       arg VARIES_P.  Call it with extra arg.
+       (true_dependence): Likewise.
+       * rtl.h (rtx_addr_can_trap_p): Declare.
+       (rtx_varies_p, rtx_addr_varies_p, true_dependence): Update
+       prototypes.
+       * rtlanal.c (rtx_addr_can_trap_p): No longer static.
+       (rtx_varies_p): Accept extra arg FOR_ALIAS; only disallow
+       pic offset table register if it's zero.  All callers changed.
+       (rtx_addr_varies_p): Accept extra arg FOR_ALIAS; all callers changed.
+
 Mon Jan  1 07:38:33 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * explow.c (convert_memory_address, case SYMBOL_REF): Copy
index 41cf596cd4115be1513c635960514b2df1c62f79..be29fc29d78572c3d32eb99316bf5d217da7865d 100644 (file)
@@ -101,7 +101,7 @@ static int insert_subset_children       PARAMS ((splay_tree_node, void*));
 static tree find_base_decl            PARAMS ((tree));
 static alias_set_entry get_alias_set_entry PARAMS ((HOST_WIDE_INT));
 static rtx fixed_scalar_and_varying_struct_p PARAMS ((rtx, rtx, rtx, rtx,
-                                                     int (*) (rtx)));
+                                                     int (*) (rtx, int)));
 static int aliases_everything_p         PARAMS ((rtx));
 static int write_dependence_p           PARAMS ((rtx, rtx, int));
 static int nonlocal_mentioned_p         PARAMS ((rtx));
@@ -1602,19 +1602,19 @@ static rtx
 fixed_scalar_and_varying_struct_p (mem1, mem2, mem1_addr, mem2_addr, varies_p)
      rtx mem1, mem2;
      rtx mem1_addr, mem2_addr;
-     int (*varies_p) PARAMS ((rtx));
+     int (*varies_p) PARAMS ((rtx, int));
 {  
   if (! flag_strict_aliasing)
     return NULL_RTX;
 
   if (MEM_SCALAR_P (mem1) && MEM_IN_STRUCT_P (mem2) 
-      && !varies_p (mem1_addr) && varies_p (mem2_addr))
+      && !varies_p (mem1_addr, 1) && varies_p (mem2_addr, 1))
     /* MEM1 is a scalar at a fixed address; MEM2 is a struct at a
        varying address.  */
     return mem1;
 
   if (MEM_IN_STRUCT_P (mem1) && MEM_SCALAR_P (mem2) 
-      && varies_p (mem1_addr) && !varies_p (mem2_addr))
+      && varies_p (mem1_addr, 1) && !varies_p (mem2_addr, 1))
     /* MEM2 is a scalar at a fixed address; MEM1 is a struct at a
        varying address.  */
     return mem2;
@@ -1644,7 +1644,7 @@ true_dependence (mem, mem_mode, x, varies)
      rtx mem;
      enum machine_mode mem_mode;
      rtx x;
-     int (*varies) PARAMS ((rtx));
+     int (*varies) PARAMS ((rtx, int));
 {
   register rtx x_addr, mem_addr;
   rtx base;
index 8959f5ed415a613a492f7f7353a5a614927b00ef..d998e42de9901dd7e406c4d16490aa516355bc2a 100644 (file)
@@ -995,7 +995,7 @@ extern const char *a29k_function_name;
    && ! (needs_regstack_p () && uses_local_reg_p (PATTERN (INSN)))     \
    && (GET_CODE (PATTERN (INSN)) != SET                                        \
        || GET_CODE (SET_SRC (PATTERN (INSN))) != MEM                   \
-       || ! rtx_varies_p (XEXP (SET_SRC (PATTERN (INSN)), 0))))
+       || ! rtx_varies_p (XEXP (SET_SRC (PATTERN (INSN)), 0), 0)))
 \f
 /* Output assembler code for a block containing the constant parts
    of a trampoline, leaving space for the variable parts.
index a961e80a27baf3408ac68bfe4b87a15410707e51..591ba579cb9d33abb11a881e5a73b7f9bb4aa0df 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -2745,7 +2745,7 @@ cse_rtx_varies_p (x)
        return 0;
     }
 
-  return rtx_varies_p (x);
+  return rtx_varies_p (x, 0);
 }
 \f
 /* Canonicalize an expression:
index f1d1b8527b3144f708fdf93969760449bb246539..1abe902015ca5bb57e34a06308dee29f063422a2 100644 (file)
@@ -540,7 +540,7 @@ equiv_init_varies_p (x)
       return 0;
 
     case REG:
-      return reg_equiv[REGNO (x)].replace == 0 && rtx_varies_p (x);
+      return reg_equiv[REGNO (x)].replace == 0 && rtx_varies_p (x, 0);
 
     case ASM_OPERANDS:
       if (MEM_VOLATILE_P (x))
@@ -604,7 +604,7 @@ equiv_init_movable_p (x, regno)
     case REG:
       return (reg_equiv[REGNO (x)].loop_depth >= reg_equiv[regno].loop_depth
              && reg_equiv[REGNO (x)].replace)
-            || (REG_BASIC_BLOCK (REGNO (x)) < 0 && ! rtx_varies_p (x));
+            || (REG_BASIC_BLOCK (REGNO (x)) < 0 && ! rtx_varies_p (x, 0));
 
     case UNSPEC_VOLATILE:
       return 0;
@@ -933,7 +933,7 @@ update_equiv_regs ()
       /* cse sometimes generates function invariants, but doesn't put a
         REG_EQUAL note on the insn.  Since this note would be redundant,
          there's no point creating it earlier than here.  */
-      if (! note && ! rtx_varies_p (src))
+      if (! note && ! rtx_varies_p (src, 0))
        REG_NOTES (insn)
          = note = gen_rtx_EXPR_LIST (REG_EQUAL, src, REG_NOTES (insn));
 
@@ -944,7 +944,7 @@ update_equiv_regs ()
 
       if (REG_N_SETS (regno) != 1
          && (! note
-             || rtx_varies_p (XEXP (note, 0))
+             || rtx_varies_p (XEXP (note, 0), 0)
              || (reg_equiv[regno].replacement
                  && ! rtx_equal_p (XEXP (note, 0),
                                    reg_equiv[regno].replacement))))
@@ -958,7 +958,7 @@ update_equiv_regs ()
 
       /* If this register is known to be equal to a constant, record that
         it is always equivalent to the constant.  */
-      if (note && ! rtx_varies_p (XEXP (note, 0)))
+      if (note && ! rtx_varies_p (XEXP (note, 0), 0))
        PUT_MODE (note, (enum machine_mode) REG_EQUIV);
 
       /* If this insn introduces a "constant" register, decrease the priority
index 54598343815673b5b4e9be638d6588a2d2ee9b54..833ff5055f16b85ce7dfd70255c0736c73c577b7 100644 (file)
@@ -4431,7 +4431,7 @@ make_memloc (ad, regno)
 
   /* If TEM might contain a pseudo, we must copy it to avoid
      modifying it when we do the substitution for the reload.  */
-  if (rtx_varies_p (tem))
+  if (rtx_varies_p (tem, 0))
     tem = copy_rtx (tem);
 
   tem = gen_rtx_MEM (GET_MODE (ad), tem);
index a79e27a737e48ce5b1f559fa166535ab12200c06..c3878774d2fca6784138c0d749d6f71f35ed11cc 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1352,9 +1352,10 @@ extern void set_unique_reg_note         PARAMS ((rtx, enum reg_note, rtx));
                       : NULL_RTX)
 #define single_set_1(I) single_set_2 (I, PATTERN (I))
 
+extern int rtx_addr_can_trap_p         PARAMS ((rtx));
 extern int rtx_unstable_p              PARAMS ((rtx));
-extern int rtx_varies_p                        PARAMS ((rtx));
-extern int rtx_addr_varies_p           PARAMS ((rtx));
+extern int rtx_varies_p                        PARAMS ((rtx, int));
+extern int rtx_addr_varies_p           PARAMS ((rtx, int));
 extern HOST_WIDE_INT get_integer_term  PARAMS ((rtx));
 extern rtx get_related_value           PARAMS ((rtx));
 extern int reg_mentioned_p             PARAMS ((rtx, rtx));
@@ -1986,7 +1987,7 @@ extern void fancy_abort PARAMS ((const char *, int, const char *))
 /* In alias.c */
 extern rtx canon_rtx                    PARAMS ((rtx));
 extern int true_dependence             PARAMS ((rtx, enum machine_mode, rtx,
-                                               int (*)(rtx)));
+                                               int (*)(rtx, int)));
 extern int read_dependence             PARAMS ((rtx, rtx));
 extern int anti_dependence             PARAMS ((rtx, rtx));
 extern int output_dependence           PARAMS ((rtx, rtx));
index a19ebeff81e08bf54bb24e11decf73a26a03b0d4..67c5319dfbf6791802f4c8a897bd2f0672383246 100644 (file)
@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA.  */
 #include "toplev.h"
 #include "rtl.h"
 
-static int rtx_addr_can_trap_p PARAMS ((rtx));
 static void reg_set_p_1                PARAMS ((rtx, rtx, void *));
 static void insn_dependent_p_1 PARAMS ((rtx, rtx, void *));
 static void reg_set_last_1     PARAMS ((rtx, rtx, void *));
@@ -113,11 +112,14 @@ rtx_unstable_p (x)
 /* Return 1 if X has a value that can vary even between two
    executions of the program.  0 means X can be compared reliably
    against certain constants or near-constants.
+   FOR_ALIAS is nonzero if we are called from alias analysis; if it is
+   zero, we are slightly more conservative.
    The frame pointer and the arg pointer are considered constant.  */
 
 int
-rtx_varies_p (x)
+rtx_varies_p (x, for_alias)
      rtx x;
+     int for_alias;
 {
   register RTX_CODE code = GET_CODE (x);
   register int i;
@@ -126,7 +128,7 @@ rtx_varies_p (x)
   switch (code)
     {
     case MEM:
-      return ! RTX_UNCHANGING_P (x) || rtx_varies_p (XEXP (x, 0));
+      return ! RTX_UNCHANGING_P (x) || rtx_varies_p (XEXP (x, 0), for_alias);
 
     case QUEUED:
       return 1;
@@ -146,19 +148,22 @@ rtx_varies_p (x)
       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
          || x == arg_pointer_rtx)
        return 0;
-#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
-      /* ??? When call-clobbered, the value is stable modulo the restore
-        that must happen after a call.  This currently screws up local-alloc
-        into believing that the restore is not needed.  */
-      if (x == pic_offset_table_rtx)
-       return 0;
+      if (x == pic_offset_table_rtx
+#ifdef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
+         /* ??? When call-clobbered, the value is stable modulo the restore
+            that must happen after a call.  This currently screws up
+            local-alloc into believing that the restore is not needed, so we
+            must return 0 only if we are called from alias analysis.  */
+         && for_alias
 #endif
+         )
+       return 0;
       return 1;
 
     case LO_SUM:
       /* The operand 0 of a LO_SUM is considered constant
         (in fact is it related specifically to operand 1).  */
-      return rtx_varies_p (XEXP (x, 1));
+      return rtx_varies_p (XEXP (x, 1), for_alias);
       
     case ASM_OPERANDS:
       if (MEM_VOLATILE_P (x))
@@ -174,14 +179,14 @@ rtx_varies_p (x)
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     if (fmt[i] == 'e')
       {
-       if (rtx_varies_p (XEXP (x, i)))
+       if (rtx_varies_p (XEXP (x, i), for_alias))
          return 1;
       }
     else if (fmt[i] == 'E')
       {
        int j;
        for (j = 0; j < XVECLEN (x, i); j++)
-         if (rtx_varies_p (XVECEXP (x, i, j)))
+         if (rtx_varies_p (XVECEXP (x, i, j), for_alias))
            return 1;
       }
 
@@ -190,7 +195,7 @@ rtx_varies_p (x)
 
 /* Return 0 if the use of X as an address in a MEM can cause a trap.  */
 
-static int
+int
 rtx_addr_can_trap_p (x)
      register rtx x;
 {
@@ -236,11 +241,14 @@ rtx_addr_can_trap_p (x)
 
 /* Return 1 if X refers to a memory location whose address 
    cannot be compared reliably with constant addresses,
-   or if X refers to a BLKmode memory object.  */
+   or if X refers to a BLKmode memory object. 
+   FOR_ALIAS is nonzero if we are called from alias analysis; if it is
+   zero, we are slightly more conservative.  */
 
 int
-rtx_addr_varies_p (x)
+rtx_addr_varies_p (x, for_alias)
      rtx x;
+     int for_alias;
 {
   register enum rtx_code code;
   register int i;
@@ -251,20 +259,20 @@ rtx_addr_varies_p (x)
 
   code = GET_CODE (x);
   if (code == MEM)
-    return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0));
+    return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0), for_alias);
 
   fmt = GET_RTX_FORMAT (code);
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     if (fmt[i] == 'e')
       {
-       if (rtx_addr_varies_p (XEXP (x, i)))
+       if (rtx_addr_varies_p (XEXP (x, i), for_alias))
          return 1;
       }
     else if (fmt[i] == 'E')
       {
        int j;
        for (j = 0; j < XVECLEN (x, i); j++)
-         if (rtx_addr_varies_p (XVECEXP (x, i, j)))
+         if (rtx_addr_varies_p (XVECEXP (x, i, j), for_alias))
            return 1;
       }
   return 0;