This is the mail archive of the gcc@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]

Re: combine_givs_p address cost


Toon Moene writes:
 > I can't see how this is possible.  Combine_givs_p should determine  
 > if givs can be combined (i.e. if two givs are related via an  
 > expression x such that x(giv1) if giv1 resides in a register is a  
 > valid addressing mode for the architecture at hand.).
 > 
 > This can only _reduce_ the number of registers used (unless  
 > combine_givs_p decides *incorrectly* that two givs can't be  
 > combined).

The problem appears to be a problem deciding which GIVs to combine.

In my example, combine_givs concludes that the GIV with the highest
benefit is in the insn (25) that explicitly multiples a BIV by a
constant.  However, this is a poor choice for GIV combination since
this insn can usually be optimised away.

With combine_givs_p modified to use the address cost, this GIV gets
the lowest benefit and thus I see much better code and (paradoxically)
fewer registers.

Here's the pertitent .loop info for my example: Note that the GIV in
insn 25 has the greatest benefit but this is the worst choice.


Loop from 16 to 49: 11 real insns.
Continue at insn 40.
Insn 43: possible biv, reg 40, const =1
Reg 40: biv verified
Biv 40 initialized at insn 15: initial value 0
Insn 25: giv reg 41 src reg 40 benefit 2 used 1 lifetime 2 replaceable ncav mult 2 add 0
Insn 27: giv reg 42 src reg 40 benefit 6 used 1 lifetime 6 replaceable ncav mult 2 add (reg/v:QI 38)
Insn 31: giv reg 44 src reg 40 benefit 6 used 1 lifetime 4 replaceable ncav mult 2 add (reg/v:QI 37)
Insn 34: dest address src reg 40 benefit 6 used 1 lifetime 1 replaceable ncav mult 2 add (reg/v:QI 37)
Insn 35: dest address src reg 40 benefit 6 used 1 lifetime 1 replaceable ncav mult 2 add (reg/v:QI 38)
Insn 37: dest address src reg 40 benefit 6 used 1 lifetime 1 replaceable mult 2 add (plus:QI (reg/v:QI 37)
    (const_int 1))
Insn 38: dest address src reg 40 benefit 6 used 1 lifetime 1 replaceable mult 2 add (plus:QI (reg/v:QI 38)
    (const_int 1))
Loop iterations: Final value not constant (reg/v:QI 39).
Cannot eliminate biv 40: biv used in insn 18.
Sorted combine statistics:
 {25, 20} {35, 18} {34, 18} {38, 15} {37, 15} {31, 12} {27, 12}
giv at 35 combined with giv at 25
giv at 34 combined with giv at 25
Sorted combine statistics:
 {31, 9} {27, 9} {38, 6} {37, 6}
giv at 37 combined with giv at 31
Sorted combine statistics:
 {27, 9} {38, 6}
giv at 38 combined with giv at 27
Sorted combine statistics:

giv at 38 reduced to (plus:QI (reg:QI 50)
    (const_int 1))
giv at 37 reduced to (plus:QI (reg:QI 49)
    (const_int 1))
giv at 35 reduced to (plus:QI (reg:QI 51)
    (reg/v:QI 38))
giv at 34 reduced to (plus:QI (reg:QI 51)
    (reg/v:QI 37))
giv at 31 reduced to (reg:QI 49)
giv at 27 reduced to (reg:QI 50)
giv at 25 reduced to (reg:QI 51)


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