[PATCH] D39536: [PowerPC] Eliminate redundant register copys after register allocation

Geoff Berry via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 10:51:05 PST 2017


gberry added a comment.

In https://reviews.llvm.org/D39536#927450, @inouehrs wrote:

> In https://reviews.llvm.org/D39536#926354, @MatzeB wrote:
>
> > Is this like the existing MachineCopyPropagation pass but working accross multiple blocks? Would https://reviews.llvm.org/D30751 solve your problem as well?
>
>
> The two optimization are mostly disjoint.
>  Copy source forwarding optimizes
>
>   mr 3, 4
>   addi 5, 3, 1 
>
>
> to
>
>   mr 3, 4
>   addi 5, 4, 1 
>
>
> but this optimization intends to rewrite
>
>   addi 4, 3, 1 
>   mr 3, 4
>
>
> to
>
>   addi 3, 3, 1 
>
>
> or eliminate
>
>   mr 4, 3
>   mr 3, 4
>


FWIW, the MachineCopyPropagation already handles eliminating the second COPY in the second case above, and could fairly easily be extended to handle the other cases once the change to mark MachineOperands as renamable lands.  It is currently limited to single block though.  It also only currently deals with instructions whose opcode is COPY (i.e. it doesn't handle other target specific copy operations).  I don't see any reason why all of these things couldn't be added to MachineCopyPropagation eventually, but I don't want to hold up your change because it might be made redundant later, especially since I can;t commit to making these extensions to MachineCopyProp.


https://reviews.llvm.org/D39536





More information about the llvm-commits mailing list