This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help with define_insn and constraints
- From: Ian Lance Taylor <ian at airs dot com>
- To: Robert Baruch <autophile at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 23 Dec 2004 12:13:42 -0500
- Subject: Re: Help with define_insn and constraints
- References: <bbac368c041223085817cf57b3@mail.gmail.com>
Robert Baruch <autophile@gmail.com> writes:
> However, by the time gcc gets to reload_cse_simplify_operands, at
> postreload.c:391, it is trying to match this insn, and fails, saying
> "insn does not satisfy its constraints":
>
> (insn 739 794 795 8 ../../Desktop/gcc-3.4.3/gcc/libgcc2.c:467 (set
> (mem/f:QI (plus:QI (mem:QI (plus:QI (reg/f:QI 49 R20/FP)
> (const_int 104 [0x68])) [6 S1 A8])
> (const_int 1 [0x1])) [2 <result>+1 S1 A8])
> (reg:QI 4 R53)) 0 {movqi} (nil)
> (nil))
>
> In other words, [ [ R20 + 104 ] +1 ] <- R53. However, this is a double
> indirection, and the "m" constraint only matches single indirection.
> But I figured gcc would split this instruction automatically in two,
> using a temporary register for the first indirection.
>
> So my question is, why doesn't it, and how do I solve this problem? I
> am having a hard time understanding when gcc has the built-in
> intelligence to move things around, and when it does not.
This kind of thing happens because gcc decides to do
(set (mem:QI (plus:QI (reg:QI pseudo) 1)) (reg:QI 4))
and then puts the pseudo on the stack and replaces it with
(mem:QI (plus:QI (reg:QI fp) 104))
Typically this kind of thing will wind up in gen_reload() in
reload1.c. That code has some heuristics to try to handle the case of
reloading an address which is a sum. When it can't figure out what to
do, it just emits a move insn and hopes for the best. So I would
start by putting a breakpoint on gen_reload() and see if this case is
winding up there, and see what it does.
If that is the problem, the usual fix is to define
LEGITIMIZE_RELOAD_ADDRESS to do something clever with frame pointer
references.
Ian