This is the mail archive of the gcc@gcc.gnu.org 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: question regarding asm()


> 
> I'm configuring GCC on a small embedded 8-bit microprocessor named CoolRISC
[snip - problem description deleted]

> I'm not yet sure how to teach reload to solve this problem.  In the meantime, I
> tried Bernd's patch and it seems to solve (or avoid) partly the problem.  The
> resulting compiler produced slightly better code, but died a few times with the
> "forbidden register was spilled" message.  Most of the time, GCC was trying to
> spill the (unneeded) frame pointer.  I applied a small patch to tell reload that
> it's OK to spill the FP when it is not needed and now I'm left with only a few
> cases where reload dies while trying to spill a forbidden (pseudo) register.

> *RAMBLING MODE OFF*
> 
> Bernd, does your patch try to address my reload problem, or is it merely a
> side effect?

I think my patch does not try to solve your problem, but since it reduces
the number of spilled registers, it's quite possible that it can avoid the
problems in some cases. My patch is mainly concerned with the allocation of
reload registers after find_reloads has done the work. There's another area
in reload that may result in suboptimal code, and which may cause your
problems: find_reloads does not try to minimize the number of registers
needed, it tries to minimize the number of instructions that need to be
generated by reload. That makes sense on machines with many registers,
but it hurts on others (like the x86). In fact, there have been cases where
there were spill failures like the one you described on the x86. I don't
recall the problem exactly, but I _think_ the instruction that triggered it
looked like this (adddi3 pattern):

(parallel
 (set (mem:DI (plus:SI (reg:SI r1) (reg:SI r2)))
      (plus:DI (mem:DI (plus:SI (reg:SI r3) (reg:SI r4)))
               (mem:DI (plus:SI (reg:SI r5) (reg:SI r6)))))
 (clobber (reg:SI r7)))

where reload decided it needed 7 registers, and the CPU unfortunately only
had 6 available. Of course it would be possible to simply reload all of the
addresses into one register each, so it would have been perfectly possible
to reload this instruction using only four registers (but more reload
instructions) without a compiler abort.
(yes, it's not exactly the same problem, but a closely related one)

Bernd



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