This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [RFC] [4.2] Address computation PRE


Richard Henderson wrote:

On Fri, Sep 30, 2005 at 08:06:45PM +0200, Paolo Bonzini wrote:


Therefore I tried to implement a restricted, but faster and more powerful form of GCSE: it looks at REG_EQUAL notes to detect address computations, gathers all the instructions depending on the one with the note, and treats them as a single entity for the sake of eliminating them.



Is there any real benefit to moving instructions, instead of emitting new code and letting rtl DCE do its job?

The problem is that sometimes the final pseudo is the same that is used in non-redundant or inserted computations (the "canonical" one holding the address), so delete_trivially_dead_insns cannot delete it.

The two properties of an address computation is being "canonical" (using the register that is picked for holding the address) and being "redundant".

A canonical but redundant computation is deleted; a non-canonical but redundant computation is left there to be DCE-ed. A canonical and non-redundant computation is left there; a non-canonical and non-redundant computation is modified to set the canonical registers (and so we do for the uses).

If you do that, then adding
a few lines to the existing GCSE pass to look at (appropriate) REG_EQUAL
notes, and invoking emit_move_insn to rebuild the sequences would seem
simpler than a new pass.


I looked (albeit very briefly) into that, but the REG_EQUAL note specifies a computation that is quite complex and emit_move_insn does not handle the "lowering" of such expressions. We cannot give

emit_move_insn (gen_reg_rtx (Pmode), a_pic_symbol_ref);

and have it call memory_address etc., or am I missing something huge?

The code building the chain of instructions computing an address would be mostly the same but in gcse.c. The code moving the instructions would be shared with GCSE of course, but would not simply be a few lines (again unless I'm missing something).

The benefit could be to detect other things, like (1 << x), in a single GCSE pass, but I don't think offhand this would be so common (maybe in long long code?). The drawback is that addrGCSE + GCSE is more powerful than the souped-up GCSE you propose, because the addrGCSE does expose common subexpressions that GCSE load motion can simplify.

Paolo


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