<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Just getting back to this now post WWDC. You are correct that I should add the negative tests, I just have a quick comment:<div><br><div><div>On May 29, 2014, at 6:49 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra">Now that the bots are happy, I wanted to do a bit of code review on the test cases here.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Thu, May 29, 2014 at 1:29 PM, Louis Gerbarg <span dir="ltr"><<a href="mailto:lgg@apple.com" target="_blank">lgg@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":6ap" class="a3s" style="overflow:hidden">Added: llvm/trunk/test/Transforms/InstCombine/gepphigep.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/gepphigep.ll?rev=209843&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/gepphigep.ll?rev=209843&view=auto</a><br>

==============================================================================<br>
--- llvm/trunk/test/Transforms/InstCombine/gepphigep.ll (added)<br>
+++ llvm/trunk/test/Transforms/InstCombine/gepphigep.ll Thu May 29 15:29:47 2014<br>
@@ -0,0 +1,56 @@<br>
+; RUN: opt -instcombine -S  < %s | FileCheck %s<br>
+<br>
+%struct1 = type { %struct2*, i32, i32, i32 }<br>
+%struct2 = type { i32, i32 }<br>
+<br>
+define i32 @test1(%struct1* %dm, i1 %tmp4, i64 %tmp9, i64 %tmp19) {<br>
+bb:<br>
+  %tmp = getelementptr inbounds %struct1* %dm, i64 0, i32 0<br>
+  %tmp1 = load %struct2** %tmp, align 8<br>
+  br i1 %tmp4, label %bb1, label %bb2<br>
+<br>
+bb1:<br>
+  %tmp10 = getelementptr inbounds %struct2* %tmp1, i64 %tmp9<br>
+  %tmp11 = getelementptr inbounds %struct2* %tmp10, i64 0, i32 0<br></div></blockquote><div><br></div><div>Why the extra (dead) GEP? It isn't used around a PHI node…</div></div></div></div></blockquote><br></div></div><div>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.</div><div><br></div><div>Louis</div></body></html>