Mark Shinwell wrote:
> The relevant RTL instructions before reload are as follows.  These
> correspond to points A, B and C respectively in my previous email.

I must admit I'm still stumbling in the dark a bit - this would be so
much easier to digest with a testcase.

The question I'm trying to answer is - why does this happen in this
testcase only, what makes it special?

> insn 5301: (set (reg/f:SI 4082) (reg/f:SI 3275))
> 
> insn 5291 (set (reg:DF 4078])
>           (mem/s:DF (plus:SI (reg/f:SI 3275) (reg:SI 3812))))
>   REG_DEAD 3275
> 
> insn 5314 (set (reg:DF 4096)
>           (mem/s:DF (plus:SI (reg/f:SI 4082) (reg:SI 4084))))

> After reload we end up with the following.  I've added dividers to show
> the correspondence with the insns above.
> 
> insn 5301 (set (mem/f/c:SI (plus:SI (reg/f:SI 13 sp) (const_int 12)))
>                (reg/f:SI 9 r9 [3275]))
> ---
> insn 6675 (set (reg:SI 9 r9)
>                (plus:SI (reg/f:SI 9 r9 [3275]) (reg:SI 10 sl [3812])))
> 
> insn 5291 (set (reg:DF 75 s12 [4078])
>                (mem/s:DF (reg:SI 9 r9)))
> ---
> insn 6680 (set (reg:SI 1 r1) (const_int 4928))
> 
> insn 6681 (set (reg:SI 1 r1)
>                (plus:SI (reg/f:SI 9 r9 [3275]) (reg:SI 1 r1)))
> 
> insn 5314 (set (reg:DF 75 s12 [4096])
>                (mem/s:DF (reg:SI 1 r1)))
> 
> We see here how pseudo 3275 was allocated to r9 and pseudo 4082 was
> spilled to the stack.  At insn 5291, r9 has been allocated [*] as the
> reload register since pseudo 3275 dies in that instruction; at insn
> 5314 we see the then-incorrect use of r9 (in instruction 6681)
> for the value of pseudo 4082.  Note also how the dump shows that the
> compiler thinks r9 still holds the value of pseudo 3275 at insn 6681.

Presumably this is one thing that is mildly unusual - R9 being chosen in
find_reloads already.  This wouldn't happen later, since it's in
reg_used_in_insn and therefore disallowed.

Still, assume a similar sequence

insn 5301: (set (reg/f:SI 4082) (reg/f:SI 3275))

insn 5291 (set (reg:DF 4078])
               (unspec:DF (mem/s:DF (plus:SI (reg/f:SI 3275)
                                             (reg:SI 3812)))
                          (reg:SI 3275)))
  REG_DEAD 3275

<some other insn where R9 is used for an input reload>

insn 5314 (set (reg:DF 4096)
          (mem/s:DF (plus:SI (reg/f:SI 4082) (reg:SI 4084))))

Here, we wouldn't use R9 as reload register in 5291, but could use it
subsequently (as it's no longer live holding 3275) for another input
reload.  Then we'd run into the same problem in insn 5314.

Still not sure why either case would be so unusual that we haven't seen
this before.


Bernd
-- 
This footer brought to you by insane German lawmakers.
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif

Reply via email to