[PATCH][Peephole] Rewrite copies to avoid cross register banks copies.
Quentin Colombet
qcolombet at apple.com
Fri Aug 23 13:04:18 PDT 2013
Hi,
Here is a patch to rewrite copies to avoid cross register banks copies when possible.
Thanks for your reviews.
** Context **
By definition copies across register bank are not coalescable. Still, it may be possible to get rid of such a copy when the value is available in another register of the same register file.
Consider the following example, where capital and lower letters denote different register file:
b = copy A <-- cross-bank copy
…
C = copy b <-- cross-bank copy
This could have been optimized this way:
b = copy A <-- cross-bank copy
…
C = copy A <-- same-bank copy
Note: b and C's definitions may be in different basic blocks.
** Proposed Solution **
Add a peephole optimization that looks through a chain of copies leading to a cross-bank copy and reuses a source that is on the same register file if available.
This solution could also be used to get rid of some copies (e.g., A could have been used instead of C). However, we do not do so because:
- It may over constrain the coloring of the source register for coalescing.
- The register allocator may not be able to find a nice split point for the longer live-range, leading to more spill.
** Testcase?! **
This patch does not include a test case, because it is very difficult to reproduce this behavior with a reasonably small input.
Cheers,
-Quentin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PeepholeCopy.svndiff
Type: application/octet-stream
Size: 5959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130823/ec7cf068/attachment.obj>
More information about the llvm-commits
mailing list