peephole optimizations

Ian Lance Taylor
Mon May 3 20:06:00 GMT 2010

roy rosen <> writes:

> 1. Is that true that if I try to match in the pattern two insns and in
> my code between these insns there is another insn which does not have
> any dependency connection to the other two, Is that true that the
> peephole would not match in this case? (i.e. the insns to match must
> come in the code in sequential order with no other insns between
> them)?


> 2. I saw that the peephole2 pass is done after IRA. Many peepholes are
> practically useless after register allocating.
> Is it possible to run it before IRA? Is it possible to run it several times?

There are also many peepholes can not be run before register
allocation, because they depend on relationships between the

Before register allocation, you should normally write an insn pattern
which can be recognized by the combine pass, rather than writing a
peephole.  To do this, write a define_insn as usual, and use
appropriate operand and insn predicates to recognize the pattern you
are looking for.

That has the advantage that it works even if random insns appear in
between the insns you care about, the case you ask about in your first
question.  (However, it does not work across block boundaries.)


More information about the Gcc mailing list