This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Reload shouldn't share in-operands with base of out-operands

On 12 Feb 2001, Alexandre Oliva wrote:

> A commercial testsuite exposed a bug in reload on sh-elf.  After lreg,
> we had:
> (set (reg:SI A) (plus:SI (reg:SI r14) (const_int 124)))
> (set (reg:SI B) (plus:SI (reg:SI A) (const_int 12)))
> where A and B were pseudos.
> B was assigned to (mem:SI (plus:SI (reg:SI r14) (const_int 148))).
> A was replaced into the second insn, so the first insn was deleted.
> LEGITIMIZE_ADDRESS modified B, and we ended up with:
> (set (mem:SI (plus:SI (plus:SI (reg:SI r14) (const_int 124))
>                       (const_int 24))) ;; operand 0
>      (plus:SI (plus:SI (reg:SI r14) (const_int 124)) ;; operand 1
>               (const_int 12) ;; operand 2
>               ))
> Reload first push_reload()ed (plus:SI (reg:SI r14) (const_int 124)) as
> a RELOAD_FOR_OUTPUT_ADDRESS.  Then, because operand 1 had a `0'
> constraint, it would push a RELOAD_OTHER for operands 0 and 1.  But
> then, it found the IN operand was identical to the first reload, so it
> decided to reuse it.
> The result was that reload generated the following sequence of insns:
> (set (reg:SI r2) (const_int 124))
> (set (reg:SI r2) (plus:SI (reg:SI r2) (reg:SI r14)))
> (set (reg:SI r2) (plus:SI (reg:SI r2) (const_int 12))) ;; orig insn
> (set (mem:SI (plus:SI (reg:SI r2) (const_int 24))) (reg:SI r2)) ;;oops
> This patch arranges for operand1 to not be shared in case it appears
> as the base address of operand0, fixing the problem.  Ok to install?

I have to admit I don't entirely follow the logic in refers_to_base_addr_p.
I'd prefer to have something that is based on replacements, i.e. if the
output is a MEM, then walk its address; if parts of it are replaced by
another reload, then we can't share with that reload.

Also, in find_reusable_reload, I'm not sure that having dont_share set
will disable merging in all cases.  The condition that uses it looks a
bit odd.

(Please include patches in the main body of the message so they can be

+static int refers_to_base_addr_p (out, in)

Small formatting problem.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]