Patchwork prevent REG_EQUAL on set-mem insns

login
register
mail settings
Submitter Olivier Hainque
Date Oct. 1, 2010, 4:35 p.m.
Message ID <20101001163538.GA14044@cardhu.act-europe.fr>
Download mbox | patch
Permalink /patch/66431/
State New
Headers show

Comments

Olivier Hainque - Oct. 1, 2010, 4:35 p.m.
Hello,

Back on this topic after a few experiments.

Steven wrote:
> I think it would be a good idea to add some code to
> set_unique_reg_note for good measure.

The patch below bootstraps and passes regression tests fine for
mainline on both x86_64-linux and ppc-aix. I'm unclear on the
importance of the potential effects.

Thinking about it, maybe REG_P alone is too restrictive: seems like
SUBREG of REG_P would be ok as well, no ?

	* emit-rtl.c (set_unique_reg_note): Don't add REG_EQUAL or REG_EQUIV
        on a SET if the destination isn't a REG.

Thanks for your feedback,

Olivier
Steven Bosscher - Oct. 23, 2010, 2:12 p.m.
On Fri, Oct 1, 2010 at 6:35 PM, Olivier Hainque <hainque@adacore.com> wrote:
> Hello,
>
> Back on this topic after a few experiments.
>
> Steven wrote:
>> I think it would be a good idea to add some code to
>> set_unique_reg_note for good measure.
>
> The patch below bootstraps and passes regression tests fine for
> mainline on both x86_64-linux and ppc-aix. I'm unclear on the
> importance of the potential effects.
>
> Thinking about it, maybe REG_P alone is too restrictive: seems like
> SUBREG of REG_P would be ok as well, no ?

I don't know. I thought REG_* notes only apply to whole regs, and not
to subregs, but I can't find a definitive answer in the internals
docs.

Ciao!
Steven
Eric Botcazou - Oct. 23, 2010, 3:11 p.m.
> I don't know. I thought REG_* notes only apply to whole regs, and not
> to subregs, but I can't find a definitive answer in the internals
> docs.

Olivier has experimented with this idea over the last few weeks and we seem to 
have measured a positive effect (small speed up) on the bootstrapped compiler 
itself.  So I think we should partially back-pedal and allow SUBREGs again.

Patch

Index: emit-rtl.c
===================================================================
--- emit-rtl.c	(revision 164744)
+++ emit-rtl.c	(working copy)
@@ -5143,6 +5143,18 @@ 
       if (GET_CODE (datum) == ASM_OPERANDS)
 	return NULL_RTX;
 
+      /* Don't add REG_EQUAL/REG_EQUIV notes on a single_set destination which
+	 isn't a REG.  Such notes are invalid, could lead to bogus assumptions
+	 downstream (e.g. that a (set MEM) couldn't trap), and many callers
+	 just don't care checking.  Note that we might have single_set (insn)
+	 == 0 here, typically from reload attaching REG_EQUAL to USEs for
+	 inheritance purposes.  */
+      {
+	rtx set = single_set (insn);
+	if (set && ! REG_P (SET_DEST (set)))
+	  return NULL_RTX;
+      }
+
       if (note)
 	{
 	  XEXP (note, 0) = datum;