re PR rtl-optimization/54900 (write introduction incorrect wrt the C11 memory model...
authorAldy Hernandez <aldyh@redhat.com>
Wed, 17 Oct 2012 20:59:40 +0000 (20:59 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Wed, 17 Oct 2012 20:59:40 +0000 (20:59 +0000)
PR rtl-optimization/54900
* ifcvt.c (noce_can_store_speculate_p): Call
memory_must_be_modified_in_insn_p.
* alias.c (memory_must_be_modified_in_insn_p): New.
(set_dest_equal_p): New.
* rtl.h (memory_must_be_modified_in_p): Protoize.

From-SVN: r192548

gcc/ChangeLog
gcc/alias.c
gcc/ifcvt.c
gcc/rtl.h

index 6571fdcd1839fe5e1173c94e10b2cd9b9f1283e1..9c6a1d96edc0de1fd290b950e5be9443e2ff7552 100644 (file)
@@ -1,3 +1,12 @@
+2012-10-17  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR rtl-optimization/54900
+       * ifcvt.c (noce_can_store_speculate_p): Call
+       memory_must_be_modified_in_insn_p.
+       * alias.c (memory_must_be_modified_in_insn_p): New.
+       (set_dest_equal_p): New.
+       * rtl.h (memory_must_be_modified_in_p): Protoize.
+
 2012-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * config/rs6000/rs6000.opt (rs6000_isa_flags): New flag word to
index 244ca520c92694095f83c9dd1a071c256698248c..c5e64176313ae990a60855d4c01cc8af17efa2f6 100644 (file)
@@ -2762,6 +2762,39 @@ memory_modified_in_insn_p (const_rtx mem, const_rtx insn)
   return memory_modified;
 }
 
+/* Return TRUE if the destination of a set is rtx identical to
+   ITEM.  */
+static inline bool
+set_dest_equal_p (const_rtx set, const_rtx item)
+{
+  rtx dest = SET_DEST (set);
+  return rtx_equal_p (dest, item);
+}
+
+/* Like memory_modified_in_insn_p, but return TRUE if INSN will
+   *DEFINITELY* modify the memory contents of MEM.  */
+bool
+memory_must_be_modified_in_insn_p (const_rtx mem, const_rtx insn)
+{
+  if (!INSN_P (insn))
+    return false;
+  insn = PATTERN (insn);
+  if (GET_CODE (insn) == SET)
+    return set_dest_equal_p (insn, mem);
+  else if (GET_CODE (insn) == PARALLEL)
+    {
+      int i;
+      for (i = 0; i < XVECLEN (insn, 0); i++)
+       {
+         rtx sub = XVECEXP (insn, 0, i);
+         if (GET_CODE (sub) == SET
+             &&  set_dest_equal_p (sub, mem))
+           return true;
+       }
+    }
+  return false;
+}
+
 /* Initialize the aliasing machinery.  Initialize the REG_KNOWN_VALUE
    array.  */
 
index 2f486a231b7dc3a1f0831b1f09ad57f3e3a2b0b7..5654c667547dca4ef0aebc11227e6316eeeaa782 100644 (file)
@@ -2415,7 +2415,7 @@ noce_can_store_speculate_p (basic_block top_bb, const_rtx mem)
                  || (CALL_P (insn) && (!RTL_CONST_CALL_P (insn)))))
            return false;
 
-         if (memory_modified_in_insn_p (mem, insn))
+         if (memory_must_be_modified_in_insn_p (mem, insn))
            return true;
          if (modified_in_p (XEXP (mem, 0), insn))
            return false;
index eeeb6ba4de0de328f3d497d6ec17c6fced3fcc0d..09f1e773899ed52d545abc9812412147be3c2cb2 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2616,6 +2616,7 @@ extern void init_alias_analysis (void);
 extern void end_alias_analysis (void);
 extern void vt_equate_reg_base_value (const_rtx, const_rtx);
 extern bool memory_modified_in_insn_p (const_rtx, const_rtx);
+extern bool memory_must_be_modified_in_insn_p (const_rtx, const_rtx);
 extern bool may_be_sp_based_p (rtx);
 extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int);
 extern rtx get_reg_known_value (unsigned int);