[PATCH] D28585: [RegisterCoalescing] Remove partial redundent copy

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 15:43:04 PST 2017


wmi created this revision.
wmi added reviewers: qcolombet, MatzeB.
wmi added subscribers: llvm-commits, davidxl.
wmi set the repository for this revision to rL LLVM.

The patch is to solve the performance problem described in PR27827.

Register coalescing sometimes cannot remove a copy because of interference. But if we can move the copy a little bit, like to its predecessors, we may find out that some of the copies moved to the predecessors are redundent. The patch handle a typical case like this:

BB0:      BB1:

  A = B    ...
  /     \    /
        BB2:
           B = A

If B = A in BB2 has a reversed copy in BB0, B = A will be redundent if the execution goes through the path from BB0 to BB2. We may remove the so called partial redundency by moving B = A to BB1.

The correctness requirement for such transformation is:

- A in B = A in BB2 is defined by the reversed copy A = B in BB0.
- No B is referenced from the start of BB2 to B = A.
- No B is defined from A = B to the end of BB0.

It is ok for BB0 to have multiple successors, but we require that BB1 has only one successor so we always move a copy to a colder place.

I got 1~2% improvement on an internal benchmark. I tested spec2000 and the performance was flat.


Repository:
  rL LLVM

https://reviews.llvm.org/D28585

Files:
  lib/CodeGen/RegisterCoalescer.cpp
  test/CodeGen/X86/pre-coalesce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28585.84037.patch
Type: text/x-patch
Size: 8802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170111/c4735159/attachment.bin>


More information about the llvm-commits mailing list