[backport gcc-4.9/trunk r199049 ] List-Archive: Date: Fri, 3 May 2013 14:10:19 +0100 From: Julian Brown Subject: [PATCH] Fix latent bug in RTL GCSE/PRE (PR57159) Hi, This is a patch which fixes a latent bug in RTL GCSE/PRE, described more fully in: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57159 I haven't been able to reproduce the problem on mainline (nor on a supported target). Maybe someone more familiar with the code in question than I am can tell if the patch is correct nonetheless? Thanks, Julian gcc/ 2013-05-17 Julian Brown * gcse.c (compute_ld_motion_mems): If a non-simple MEM is found in a REG_EQUAL note, invalidate it. --- gcc-4.7.3/gcc/gcse.c.~1~ 2012-11-27 21:26:57.000000000 +0100 +++ gcc-4.7.3/gcc/gcse.c 2013-05-18 11:52:19.121141687 +0200 @@ -3482,6 +3482,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)) @@ -3498,6 +3500,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