[llvm] r209843 - Add support for combining GEPs across PHI nodes
Louis Gerbarg
lgg at apple.com
Mon Jun 9 14:10:34 PDT 2014
Just getting back to this now post WWDC. You are correct that I should add the negative tests, I just have a quick comment:
On May 29, 2014, at 6:49 PM, Chandler Carruth <chandlerc at google.com> wrote:
> Now that the bots are happy, I wanted to do a bit of code review on the test cases here.
>
> On Thu, May 29, 2014 at 1:29 PM, Louis Gerbarg <lgg at apple.com> wrote:
> Added: llvm/trunk/test/Transforms/InstCombine/gepphigep.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/gepphigep.ll?rev=209843&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/gepphigep.ll (added)
> +++ llvm/trunk/test/Transforms/InstCombine/gepphigep.ll Thu May 29 15:29:47 2014
> @@ -0,0 +1,56 @@
> +; RUN: opt -instcombine -S < %s | FileCheck %s
> +
> +%struct1 = type { %struct2*, i32, i32, i32 }
> +%struct2 = type { i32, i32 }
> +
> +define i32 @test1(%struct1* %dm, i1 %tmp4, i64 %tmp9, i64 %tmp19) {
> +bb:
> + %tmp = getelementptr inbounds %struct1* %dm, i64 0, i32 0
> + %tmp1 = load %struct2** %tmp, align 8
> + br i1 %tmp4, label %bb1, label %bb2
> +
> +bb1:
> + %tmp10 = getelementptr inbounds %struct2* %tmp1, i64 %tmp9
> + %tmp11 = getelementptr inbounds %struct2* %tmp10, i64 0, i32 0
>
> Why the extra (dead) GEP? It isn't used around a PHI nodeā¦
Ignoring the fact that the GEP is dead the reason that it is there is because %tmp10 feeds both %tmp11 and the phi. Prior to this patch not only was the GEP->PHI->GEP not being folded, but %tmp10 andf %tmp11 would not be folded because %tmp10 had another use. This checks that once new GEP generated breaks that use and allows %tmp10 and %tmp11 to be folded together since %tmp10 has only a single use at that point. The fact that %tmp11 is dead is just an artifact of how I extracted the reduction and the fact that llc will not eliminate it given the arguments being passed to it.
Louis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140609/1a7562c9/attachment.html>
More information about the llvm-commits
mailing list