[PATCH] D11197: [PeepholeOptimizer] Look through PHIs to find additional register sources
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Tue Jul 14 13:48:21 PDT 2015
bruno created this revision.
bruno added reviewers: qcolombet, MatzeB.
bruno added a subscriber: llvm-commits.
bruno set the repository for this revision to rL LLVM.
The PeepholeOptimizer misses some rewrite opportunities since it can't look through PHI instructions.
This patch implements looking through PHIs while trying to rewrite Uncoalescable copies.
It depends on the refactoring posted in: http://reviews.llvm.org/D11195
Changes include:
- Improve the ValueTracker in the PeepholeOptimizer to look through PHI instructions.
- Teach findNextSource to lookup into multiple sources returned by the ValueTracker and generate a rewrite map for clients to consume.
- Although all support is there, don't enable this for coalescable copies until we get the motivating testcases.
- Limit the length of nested PHI chains to lookup to avoid potential compile time issues. This can further improved in the presence of compelling testcases.
With these changes we can find more register sources and rewrite more copies to allow coaslescing of bitcast instructions.
Hence, we eliminate unnecessary VR64 <-> GR64 copies in x86, but it could be extended to other archs by marking "isBitcast"
on target specific instructions.
A x86 MMX example follows:
A:
psllq %mm1, %mm0
movd %mm0, %r9
jmp C
B:
por %mm1, %mm0
movd %mm0, %r9
jmp C
C:
movd %r9, %mm0
pshufw $238, %mm0, %mm0
Becomes:
A:
psllq %mm1, %mm0
jmp C
B:
por %mm1, %mm0
jmp C
C:
pshufw $238, %mm0, %mm0
Repository:
rL LLVM
http://reviews.llvm.org/D11197
Files:
include/llvm/Target/TargetInstrInfo.h
lib/CodeGen/PeepholeOptimizer.cpp
lib/Target/X86/X86InstrMMX.td
test/CodeGen/X86/mmx-coalescing.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11197.29707.patch
Type: text/x-patch
Size: 26517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150714/1f7f6bfd/attachment.bin>
More information about the llvm-commits
mailing list