cse.c (cse_insn): When SETting (MEM (ADDRESSOF (X))) to Y...
authorMark Mitchell <mark@markmitchell.com>
Sun, 5 Jul 1998 23:33:36 +0000 (23:33 +0000)
committerJeff Law <law@gcc.gnu.org>
Sun, 5 Jul 1998 23:33:36 +0000 (17:33 -0600)
        * cse.c (cse_insn): When SETting (MEM (ADDRESSOF (X))) to Y,
        don't claim that the former is equivalent to the latter.

From-SVN: r20935

gcc/ChangeLog
gcc/cse.c

index 8e9c2e4c42b17d89d55db26c1ed8312cfb30065e..30275b20a2639eeff06084abc81e71d56c2dd9f7 100644 (file)
@@ -1,3 +1,8 @@
+Mon Jul  6 00:28:43 1998  Mark Mitchell  <mark@markmitchell.com>
+
+       * cse.c (cse_insn): When SETting (MEM (ADDRESSOF (X))) to Y,
+       don't claim that the former is equivalent to the latter.
+
 Sun Jul  5 23:58:19 1998  Jeffrey A Law  (law@cygnus.com)
 
        * combine.c (simplify_comparison): Do not commute a AND into
index 37055110575fa0c0756a03f52a467de22debe644..055bbd90e2c20fbc67f1355cd11eec6c5904072d 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -7405,6 +7405,7 @@ cse_insn (insn, in_libcall_block)
     if (sets[i].rtl)
       {
        register rtx dest = SET_DEST (sets[i].rtl);
+       rtx inner_dest = sets[i].inner_dest;
        register struct table_elt *elt;
 
        /* Don't record value if we are not supposed to risk allocating
@@ -7453,8 +7454,18 @@ cse_insn (insn, in_libcall_block)
              sets[i].dest_hash = HASH (dest, GET_MODE (dest));
            }
 
-       elt = insert (dest, sets[i].src_elt,
-                     sets[i].dest_hash, GET_MODE (dest));
+       if (GET_CODE (inner_dest) == MEM
+           && GET_CODE (XEXP (inner_dest, 0)) == ADDRESSOF)
+         /* Given (SET (MEM (ADDRESSOF (X))) Y) we don't want to say
+            that (MEM (ADDRESSOF (X))) is equivalent to Y. 
+            Consider the case in which the address of the MEM is
+            passed to a function, which alters the MEM.  Then, if we
+            later use Y instead of the MEM we'll miss the update.  */
+         elt = insert (dest, 0, sets[i].dest_hash, GET_MODE (dest));
+       else
+         elt = insert (dest, sets[i].src_elt,
+                       sets[i].dest_hash, GET_MODE (dest));
+
        elt->in_memory = (GET_CODE (sets[i].inner_dest) == MEM
                          && (! RTX_UNCHANGING_P (sets[i].inner_dest)
                              || FIXED_BASE_PLUS_P (XEXP (sets[i].inner_dest,