[Patch,avr]: Ad PR rtl-optimization/52543: Undo the MEM->UNSPEC hack
Georg-Johann Lay
avr@gjlay.de
Sun Sep 30 15:36:00 GMT 2012
Denis Chertykov schrieb:
> Georg-Johann Lay:
>> PR52543 required to represent a load from non-generic address spaces as UNSPEC
>> instead of as MEM to avoid a gross code bloat.
>>
>> http://gcc.gnu.org/PR52543
>>
>> lower-subreg's cost model is still broken: It assumes that any loads from MEM
>> are from the generic address space and does not care for address spaces in its
>> cost model.
>>
>> This patch undoes the changes from SVN r185605
>>
>> http://gcc.gnu.org/viewcvs?view=revision&revision=185605
>>
>> and installs a different but less intrusive hack around PR52543:
>>
>> targetm.mode_dependent_address_p has an address space parameter so that the
>> backend can pretend all non-generic addresses are mode-dependent.
>>
>> This keeps lower-subreg.c from splitting the loads, and it is possible to
>> represent the loads as MEM and there is no more the need to represent them as
>> UNSPECs.
>>
>> This patch is still not an optimal solution but the code is much closer to a
>> clean solution now.
>>
>> Ok for trunk?
>
> You can apply it.
>
> Denis.
I also applied the following change:
http://gcc.gnu.org/viewcvs?view=revision&revision=191825
* config/avr/avr.md (adjust_len): Add lpm.
(reload_in<mode>): Use avr_out_lpm for output. Use "lpm" for
adjust_len.
* config/avr/avr-protos.h (avr_out_lpm): New prototype.
* config/avr/avr.c (avr_out_lpm): Make global.
(adjust_insn_length): Handle ADJUST_LEN_LPM.
The reload_in<mode> insns used the wrong output functions.
Notice that this change is just a cosmetic change because the secondary
reload for the non-generic spaces are ignored. That is: despite
avr_secondary_reload, REG <- MEM input reloads are not mapped to their
secondary reload insn and the mov insn for that load is used.
This leads to a situation where the insn output function is not supplied
with the needed clobber register, thus the avr_find_unused_d_reg
function is needed to work around that.
Sigh. Even more FIXMEs in the avr backend...
Denis, do you know why the secondary reloads requested by
avr_secondary_reload are ignored? I see calls to this hook and
sri->icode is set to the right insn code but ignored afterwards.
The only calls to that hook with the right operands are from ira cost
computation.
From the internals I don't see why it is skipped and the responsiveness
in the gcc-help@ list on such topics is zero :-(
A test case is
$ avr-gcc -mmcu=atmega128 -S -std=gnu99 ...
int read (const __flash1 int *p)
{
return *p;
}
Johann
More information about the Gcc-patches
mailing list