[PeepholeOptimizer] Advanced rewriting of copies to avoid cross register banks
authorQuentin Colombet <qcolombet@apple.com>
Tue, 1 Jul 2014 14:33:36 +0000 (14:33 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Tue, 1 Jul 2014 14:33:36 +0000 (14:33 +0000)
commit1111e6fe8411fb2251ee3b3ab7c0bd5919cb04c2
tree669e32e082b0f1a6f379bd58f7707a64219cf971
parente1a36634b742e3fe28ecb2c0eb9ba1257ecb1754
[PeepholeOptimizer] Advanced rewriting of copies to avoid cross register banks
copies.

This patch extends the peephole optimization introduced in r190713 to produce
register-coalescer friendly copies when possible.

This extension taught the existing cross-bank copy optimization how to deal
with the instructions that generate cross-bank copies, i.e., insert_subreg,
extract_subreg, reg_sequence, and subreg_to_reg.
E.g.
b = insert_subreg e, A, sub0 <-- cross-bank copy
...
C = copy b.sub0 <-- cross-bank copy

Would produce the following code:
b = insert_subreg e, A, sub0 <-- cross-bank copy
...
C = copy A <-- same-bank copy

This patch also introduces a new helper class for that: ValueTracker.
This class implements the logic to look through the copy related instructions
and get the related source.

For now, the advanced rewriting is disabled by default as we are lacking the
semantic on target specific instructions to catch the motivating examples.

Related to <rdar://problem/12702965>.

llvm-svn: 212100
llvm/include/llvm/CodeGen/MachineInstr.h
llvm/lib/CodeGen/PeepholeOptimizer.cpp