diff mbox

lra: Don't remove the scratch in (mem:BLK (scratch))

Message ID 353f94852b9a7aa6291d3667497644a0575467be.1446136464.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool Oct. 29, 2015, 4:40 p.m. UTC
LRA wants to replace SCRATCH registers with real registers.  It should
not do that with (mem:BLK (scratch)), which is special, not really a
scratch register.

I don't know if this patch handles this in the best place to handle it;
I don't even know if it is really correct.  It does solve the rs6000
bootstrap problems with LRA enabled by default (it ICEd building libitm),
with no apparent ill effects.

It seems other targets can do without this.  rs6000 uses this construct
inside of a PARALLEL, maybe that is the difference?

Any hints appreciated!


Segher


2015-10-29  Segher Boessenkool  <segher@kernel.crashing.org>

	* lra-constraints.c (process_address_1): Handle (mem:BLK (scratch))
	by ignoring it.

---
 gcc/lra-constraints.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Vladimir Makarov Oct. 29, 2015, 5:29 p.m. UTC | #1
On 10/29/2015 12:40 PM, Segher Boessenkool wrote:
> LRA wants to replace SCRATCH registers with real registers.  It should
> not do that with (mem:BLK (scratch)), which is special, not really a
> scratch register.
>
> I don't know if this patch handles this in the best place to handle it;
> I don't even know if it is really correct.  It does solve the rs6000
> bootstrap problems with LRA enabled by default (it ICEd building libitm),
> with no apparent ill effects.
>
Segher, thanks for working on this issue.

LRA removes scratches temporary and restore them but only for insn 
operands.  This is done to get a better allocation results as scratch 
might need a register and this should be taken in to account by other 
pseudos allocations.  The mentioned construction is used for different 
purposes and was missed from the LRA consideration.

The patch is perfectly fine and fixes the problem in the right place.

So please go ahead and commit this patch into the trunk.
diff mbox

Patch

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index bc7a292..b04b426 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -2877,6 +2877,11 @@  process_address_1 (int nop, bool check_only_p,
   enum constraint_num cn = lookup_constraint (constraint);
   bool change_p = false;
 
+  if (MEM_P (op)
+      && GET_MODE (op) == BLKmode
+      && GET_CODE (XEXP (op, 0)) == SCRATCH)
+    return false;
+
   if (insn_extra_address_constraint (cn))
     decompose_lea_address (&ad, curr_id->operand_loc[nop]);
   else if (MEM_P (op))