[PATCH] Add support for combining GEPs across PHI nodes

David Majnemer david.majnemer at gmail.com
Fri May 16 16:40:11 PDT 2014

The patch contains dyn_cast<Instruction> calls which are then immediately
dereferenced. This looks a bit odd, should those be replaced with
cast<Instruction> ?

On Fri, May 16, 2014 at 3:21 PM, Louis Gerbarg <lgg at apple.com> wrote:

> 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
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140516/d5c9c046/attachment.html>

More information about the llvm-commits mailing list