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

--- Comment #6 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #5)
> Maybe I'm missing something here.  We have this immediately prior to IRA:
> 

> ISTM that we want (reg 86) to prefer di and (reg 87) to prefer ax by way of
> the hard register copies.  (reg 88) should then prefer di by way of insn 6.
> 
> (reg 89) really doesn't need a preference and can go anywhere that doesn't
> conflict.
> 
> So if we look at the IRA dump we have:
> 
> Pass 1 for finding pseudo/allocno costs
> 
>     r89: preferred GENERAL_REGS, alternative NO_REGS, allocno GENERAL_REGS
>     r88: preferred GENERAL_REGS, alternative NO_REGS, allocno GENERAL_REGS
>     r87: preferred AREG, alternative GENERAL_REGS, allocno GENERAL_REGS
>     r86: preferred DIREG, alternative GENERAL_REGS, allocno GENERAL_REGS
> 
> Which I guess is OK.  A bit surprised to not see r88 preferring DIreg at
> this point, but I guess copies implied by the 2 operand nature are handled
> later.
> 
> ISTM that the copy implied by insn 6 should result in 88 somehow preferring
> DIreg.  Then, ideally we'd see that while 89 can go anywhere it's best to
> match it with 87.
> 
> Vlad, what am I missing here?

Preferred/alternative class is misleading here.  It is not used anywhere in
IRA/LRA for allocation decision (but may be it is used by reload -- i don't
remember).  It is only used as a temporary result for allocno class
calculation.

Hard reg preferences and copies are further in the dump.  They looks as
following

cp0:a2(r88)<->a3(r86)@1000:constraint
cp1:a0(r87)<->a1(r89)@1000:constraint
cp2:a0(r87)<->a2(r88)@1000:constraint
pref0:a0(r87)<-hr0@1500
pref1:a3(r86)<-hr5@1500

This problem is well known me.  Jakub filled analogous PR.  I am working on it.
 The reason of the problem are copies created for commutative ops insns.  Two
copies give different signals for hard reg preferences through the propagation
mechanism.  It is easy to make a test for this problem because the test should
be small and involve arguments and result on small number of insns.  Therefore
we have a few such PRs.  In bigger function, the probability of the problem
occurrence is quite small.

Reply via email to