The problem in front of me is something like this..

op0 = 1
op1 = op0 leftshift op2

The above is a part of the template to be matched, with one of the conditions that op0 should be dead after the 2nd insn.
This will be optimized to
op1 = 1 leftshift op2 (by the peephole2 pass to the rtl pattern corresponding to this and hence the requirement that op0 should be dead after insn2) Under normal conditions (op0 dead after the pattern) both peep2_dead_reg_p and dead_or_set_p give same results.


However if the pattern happens to be something like this :

op0 = 1
op0 = op0 leftshift op2
...
use of op0 here
...

The pattern matches in any case.
The condition should also match, because although op0 is not dead after the pattern, the 2nd insn in the pattern itself sets op0. Hence, it can be optimized. This is done by dead_or_set_p.

However, peep2_reg_dead_p checks only the liveness information and says op0 is not dead after the pattern and says that the condition is not satisfied, so although the pattern matches, the conditions don't and hence the peephole2 also doesn't. In this sense, i thought dead_or_set_p is smarter than peep2_dead_reg_p since it also checks if the insn sets the operand.


Regards,
Ashwin



Richard Henderson wrote:

On Wed, Aug 24, 2005 at 06:50:25PM +0530, Ashwin wrote:
The pattern matches in the original peephole pass because the peephole pass happens just before assembly generation, when the 3 insns are present together. Has anybody encountered a similar problem?

No, or at least havn't looked.

Does this mean that peephole2 and peephole both should be kept on.

No.  It would be possible to run peep2 more than once.
Noone has shown a need for it yet.

Secondly, after taking a look at other ports, i realised that all are using peep2_dead_reg_p instead of dead_or_set_p to check if a register is dead. The former is smarter than the later in the sense that it also checks if the current insn "sets" the register which is to be verified as dead. So, why do other ports use peep2_reg_dead_p instead of dead_or_set_p. Pls help me to find the advantages of using peep2_reg_dead_p over its counterpart.

My guess is that your misunderstanding is that you're not
realizing that you can ask peep2_dead_reg_p about the state of a register at the beginning of the N+1 insn in
the sequence.  That is, after the entire sequence is over.

peep2_dead_reg_p *is* smarter than dead_or_set_p.



r~


Reply via email to