diff mbox

Fix latent bug in RTL GCSE/PRE (PR57159)

Message ID 5196FB36.2000101@redhat.com
State New
Headers show

Commit Message

Jeff Law May 18, 2013, 3:53 a.m. UTC
On 05/07/2013 09:05 AM, Julian Brown wrote:
> On Mon, 6 May 2013 11:53:20 -0600
>
> I don't know. My assumption was that a "simple" mem would be one that
> the PRE pass could handle -- that clause was intended to handle simple
> mems in REG_EQUAL notes the same as simple mems as the source of a set.
> Maybe that is not safe though, and it would be better to
> unconditionally invalidate buried mems in REG_EQUAL notes? I was
> slightly wary of inhibiting genuine optimisation opportunities.
For a simple mem, we'll do the right thing, at least that's my reading 
of the code.

I went ahead and put the two code fragments together and committed the 
change after a bootstrap and regression test on x86_64-unknown-linux-gnu.

For reference, attached is the patch that ultimately went into the tree.

Thanks,
Jeff
commit f473eb72a23bc82db0ee23e51fdd40b20417fb15
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sat May 18 03:48:18 2013 +0000

           * gcse.c (compute_ld_motion_mems): If a non-simple MEM is
           found in a REG_EQUAL note, invalidate it.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199049 138bc75d-0d04-0410-961f-82ee72b054a4
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4536e62..d6eab5f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2013-05-17  Julian Brown  <julian@codesourcery.com>
+
+	* gcse.c (compute_ld_motion_mems): If a non-simple MEM is
+	found in a REG_EQUAL note, invalidate it.
+
 2013-05-17   Easwaran Raman  <eraman@google.com>
 
 	* tree-ssa-reassoc.c (find_insert_point): New function.
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 07043f7..e485985 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -3894,6 +3894,8 @@  compute_ld_motion_mems (void)
 		{
 		  rtx src = SET_SRC (PATTERN (insn));
 		  rtx dest = SET_DEST (PATTERN (insn));
+		  rtx note = find_reg_equal_equiv_note (insn);
+		  rtx src_eq;
 
 		  /* Check for a simple LOAD...  */
 		  if (MEM_P (src) && simple_mem (src))
@@ -3910,6 +3912,15 @@  compute_ld_motion_mems (void)
 		      invalidate_any_buried_refs (src);
 		    }
 
+		  if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)
+		    src_eq = XEXP (note, 0);
+		  else
+		    src_eq = NULL_RTX;
+
+		  if (src_eq != NULL_RTX
+		      && !(MEM_P (src_eq) && simple_mem (src_eq)))
+		    invalidate_any_buried_refs (src_eq);
+
 		  /* Check for stores. Don't worry about aliased ones, they
 		     will block any movement we might do later. We only care
 		     about this exact pattern since those are the only