Hi,

I'd like to gentle ping this:

https://gcc.gnu.org/pipermail/gcc-patches/2020-December/561413.html


BR,
Kewen

on 2020/12/9 下午5:49, Kewen.Lin via Gcc-patches wrote:
> Hi,
> 
> This patch is to treat those new pseudo-to-pseudo copies
> after hard-reg-to-pseudo-copy as zero costs.  The
> justification is that these new copies are closely after
> the corresponding hard-reg-to-pseudo-copy insns, register
> allocation should be able to coalesce them and get them
> eliminated.
> 
> Now these copies follow the normal costing scheme, the
> below case dump shows the unexpected combination:
> 
> ``` dump
> 
> Trying 3, 2 -> 13:
>     3: r119:DI=r132:DI
>       REG_DEAD r132:DI
>     2: r118:DI=r131:DI
>       REG_DEAD r131:DI
>    13: r128:DI=r118:DI&0xffffffff|r119:DI<<0x20
>       REG_DEAD r119:DI
>       REG_DEAD r118:DI
> 
> Failed to match this instruction:
> (set (reg:DI 128)
>     (ior:DI (ashift:DI (reg:DI 132)
>             (const_int 32 [0x20]))
>         (reg:DI 131)))
> Successfully matched this instruction:
> (set (reg/v:DI 119 [ f2 ])
>     (ashift:DI (reg:DI 132)
>         (const_int 32 [0x20])))
> Successfully matched this instruction:
> (set (reg:DI 128)
>     (ior:DI (reg/v:DI 119 [ f2 ])
>         (reg:DI 131)))
> allowing combination of insns 2, 3 and 13
> original costs 4 + 4 + 4 = 12
> replacement costs 4 + 4 = 8
> deferring deletion of insn with uid = 2.
> modifying insn i2     3: r119:DI=r132:DI<<0x20
>       REG_DEAD r132:DI
> deferring rescan insn with uid = 3.
> modifying insn i3    13: r128:DI=r119:DI|r131:DI
>       REG_DEAD r131:DI
>       REG_DEAD r119:DI
> deferring rescan insn with uid = 13.
> 
> ``` end dump
> 
> The original insn 13 can work well as rotldi3_insert_3,
> so the combination with shift/or isn't better, but the
> costing doesn't matches.
> 
> With this patch, we get below instead:
> 
> rejecting combination of insns 2, 3 and 13
> original costs 0 + 0 + 4 = 4
> replacement costs 4 + 4 = 8
> 
> 
> Bootstrapped/regtested on powerpc64le-linux-gnu P9.
> 
> Is it reasonable?  Any comments are highly appreciated!
> 
> BR,
> Kewen
> ------
> gcc/ChangeLog:
> 
>       * combine.c (new_copies): New static global variable declare/init.
>       (combine_validate_cost): Consider zero costs from new_copies.
>       (combine_instructions): Set zero cost for insns in new_copies.
>       (make_more_copies): Record new pseudo-to-pseudo copies to new_copies.
>       (rest_of_handle_combine): Call bitmap alloc/free for new_copies.
> 

Reply via email to