Patchwork Improve regcprop find_oldest_value_reg

login
register
mail settings
Submitter Richard Henderson
Date Dec. 17, 2010, 11:08 p.m.
Message ID <4D0BED5C.7040903@redhat.com>
Download mbox | patch
Permalink /patch/76002/
State New
Headers show

Comments

Richard Henderson - Dec. 17, 2010, 11:08 p.m.
While syncing data between my laptop and my desktop, I found a 
lost patch.  I believe the original context was mn10300, where
SP may only be copied to ADDRESS_REGS, but not DATA_REGS, and
SP may not be involved in any other arithmetic besides SP+=IMM.
Thus when computing something like

	p0 = &local0
	p1 = &local1
we get
	(set A0 SP)
	(set P0 IMM)
	(set P0 (plus P0 A0))
	(set A1 SP)
	(set P1 IMM)
	(set P1 (plus P1 A1))

The regcprop chain created in this context will always begin
with SP, which is not a member of GENERAL_REGS, which would
immediately exit the function rather than discovering that A0
is the second oldest copy and is of the proper class.  After
this substitution, we can find that the A1=SP copy is dead.

I've bootstrapped this patch on x86_64-linux for sanity and
committed it, though of course no effect was expected there.


r~
* regcprop.c (find_oldest_value_reg): Continue search instead of
	failing if an element in the copy chain is of the wrong regclass.

Patch

diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 88f9226..0f0dfb3 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -457,7 +457,7 @@  find_oldest_value_reg (enum reg_class cl, rtx reg, struct value_data *vd)
       rtx new_rtx;
 
       if (!in_hard_reg_set_p (reg_class_contents[cl], mode, i))
-	return NULL_RTX;
+	continue;
 
       new_rtx = maybe_mode_change (oldmode, vd->e[regno].mode, mode, i, regno);
       if (new_rtx)