PR 27073: invalid gcse manipulation of REG_EQUIV notes

Roger Sayle
Sat Apr 8 17:33:00 GMT 2006

On Sat, 8 Apr 2006, Richard Sandiford wrote:
> 	PR rtl-optimization/27073
> 	* gcse.c (try_replace_reg): Just propagate into REG_EQUAL notes,
> 	not REG_EQUIVs.

I agree with your analysis.  This is OK for mainline.

On the off chance that the potential performance problems you describe
might materialize, there are several fallback alternatives to this PR.
One alternative fix might be to disable just the problematic bit of
try_replace_reg, i.e. to change:

> /* If there is already a NOTE, update the expression in it with our
>    replacement.  */
> if (note != 0)
>    XEXP (note, 0) = simplify_replace_rtx (XEXP (note, 0), from, to);

into some thing like:

   /* If there is already a REG_EQUAL note, update ... */
   if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)

And another alternative, might be to convert this note from a
REG_EQUIV into a REG_EQUAL [if the result isn't identical to the
SET_SRC, and delete it otherwise].

I'd be interested in seeing whether this does adversely affect
performance through inferior register allocation.  If it does,
there may be some merit to rewriting update_equiv_regs in local-alloc.c
which currently throws away a significant number of REG_EQUAL and
REG_EQUIV notes before register allocation!

Thanks for addressing this,


More information about the Gcc-patches mailing list