[PATCH] Add support for combining GEPs across PHI nodes
Louis Gerbarg
lgg at apple.com
Fri May 16 15:21:18 PDT 2014
The attached patch modifies InstCombine’s GEP code to merge GEPs that are split apart by PHIs. The existing code already generally merges GEP chains as aggressively as it can unless intermediary parts of the chain have additional uses that cannot be combined, so this patch makes the GEP chain folding more consistent overall. It also allows the target independent optimizer to hand more expressive GEPs to the backends, which can then use more complex addressing modes when appropriate. More details of the actual mechanics are in the patch.
A concrete example of why want to do this is:
unsigned testu(llvm::DenseMap<unsigned, unsigned> &dm, unsigned key) {
return dm.lookup(key);
}
The generated code includes the following assembly:
LBB0_6:
leaq (%r8,%rdi,8), %rax
movl 4(%rax), %eax
which can be merged into a single instruction by the x86 backend provided the GEPs are merged across a PHI.
LBB0_6: ## %if.then.i
movl 4(%r8,%rdi,8), %eax
Louis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-support-for-combining-GEPs-across-PHI-nodes.patch
Type: application/octet-stream
Size: 7143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140516/ad237082/attachment.obj>
More information about the llvm-commits
mailing list