[PATCH] D65267: [PowerPC][PreEmitPeephole] Remove redundant copies of immediate numbers after TailDup

Kai Luo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 19:38:46 PDT 2019


lkail added a comment.

>   //   $reg0 = OP ....
>   // ...
>   //   $reg1 = COPY $reg0
> 
> 
> If we can be sure that `$reg0` is renamable, and no use of `$reg0` or `$reg1` in between (and of course there might be other restrictions, like ReservedReg etc),
>  we should be able to remove the COPY here.
> 
>   // `$reg1` = OP ..
>   // ...

One concern here, there might be uses of `$reg0` in succ BBs. To overcome it, we might constraint this opt in terminal BBs considering current machine-cp working on single BB. To summarize, without complex uses and defs(thus we don't need to do complex replace-uses-with after RA), in a terminal BB we should have

  $reg0 = OP ...
  ... <<< No uses of $reg0 and $reg1
  $reg1 = COPY $reg0 <<< $reg0 is killed
  ...
  <RET>

For complex scenes,

  $reg0 = OP ...
  ... <<< No uses of $reg1, might have uses of $reg0
  $reg1 = COPY $reg0
  ...
  $reg1 = OP ...
  ... <<< If there are uses of $reg0, seems not profitable to conduct this opt.
  $reg0 = OP ...
  <RET>




Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65267/new/

https://reviews.llvm.org/D65267





More information about the llvm-commits mailing list