http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50063

--- Comment #13 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-12-19 
18:56:49 UTC ---
(In reply to comment #12)
> I believe this is just because of very weird target avr stuff, either it is a
> target bug that can be fixed up in the backend somehow, or perhaps would need
> some middle-end help, but still it is avr specific.

The insns describe exactly what the machine is doing:

insn 43/44: Save FP (r28/29) to Stack. This in done in two QI pushes and not in
one HI. SP push is post-decrement and with a HI push the resulting address
would be wrong. AVR is 8-bit machine with 16-bit PMODE.

insn 45: Initialize FP with SP

insn 46: Set up a frame (12 bytes here). AVR's SP cannot be changed directly,
not even atomically so changing SP is quite expensive and IRQs must be turned
off. Therefore, prologue generation works out two methods of setting up
frame/changing SP and picks the most efficient:

* For big offsets it is:
    FP = SP;
    FP -= const;
    SP = FP

* For small offsets SP is adjusted by dummy pushes/pops, for example:
    SP -= 2 as of: push(dummy); push(dummy);
    FP = SP

Similar applies to epilogue generation.

This example exercises the first approach. The 3rd step is (SP = FP):

insn 47: Write back SP

If the generic analysis ignores prologue/epilogue but optimizers optimize
against prologue/epilogue using that incorrect information based on lazy
analysis, then the problem is in generic code.

Reply via email to