<div dir="ltr">Updated patch attached<br><br><div class="gmail_quote">On Fri Jan 30 2015 at 1:58:04 PM Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote">On Wed Jan 28 2015 at 9:51:02 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[moving to llvm-commits for patch review]<br>
<br>
Hi Danny,<br>
<br>
This seems reasonable to me.<br>
<br>
You're patch has tabs in it, which you'll need to remove ;)<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Sorry, i haven't had emacs set up for llvm in a while :)</div><div>I'll make sure it happens</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
+; <label>:6                                       ; preds = %4, %2<br>
+; CHECK: pre-phi<br>
+; CHECK-NEXT: ret i32 %.pre-phi<br>
+  %7 = add nsw i32 %a, %b<br>
+  ret i32 %7<br>
<br>
I'd like to see this test case be more explicit about what it is expecting. Can you please check for the new phi you're expecting with its value, and then check that it is returned?<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Will do.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks again,<br>
Hal<br>
<br>
----- Original Message -----<br>
> From: "Daniel Berlin" <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>><br>
> To: "LLVM Developers Mailing List" <<a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a>><br>
> Sent: Wednesday, January 28, 2015 5:15:20 PM<br>
> Subject: [LLVMdev] [PATCH]: Allow PRE to insert no-cost phi nodes<br>
><br>
><br>
><br>
> Current PRE tries to not increase code size.<br>
> It does this with a check whether or not the number of places it<br>
> would have to insert is 1 or not.<br>
><br>
><br>
> The problem with this is that the answer could also be "we have to<br>
> insert in zero places" in the case it's available in all<br>
> predecessors.<br>
> :)<br>
><br>
><br>
> Normal dominator based elimination in GVN will not catch these cases<br>
> because the branches do not dominate the merge point.<br>
><br>
><br>
> A simple example<br>
> int c;<br>
><br>
> int d;<br>
> int pre(int foo, int a, int b)<br>
> {<br>
> int g;<br>
> if (foo) {<br>
> c = a+b;<br>
> } else {<br>
> d = a+ b;<br>
> }<br>
> g = a+b;<br>
> return g;<br>
> }<br>
><br>
><br>
> Without this patch, PRE (and GVN) will not eliminate g = a+b.<br>
> With this patch, PRE will create phi(c, d) and eliminate g = a + b.<br>
><br>
><br>
> (It is tremendously more difficult to make current GVN understand the<br>
> problem, and GCC solves this the same way i'm about to).<br>
><br>
><br>
> The patch looks large because of code movement, but it basically all<br>
> boils down to changing this check:<br>
><br>
><br>
> if (NumWithout != 1 || NumWith == 0)<br>
><br>
><br>
> to<br>
> if (NumWithout > 1 || NumWith == 0)<br>
><br>
><br>
> and skipping insertion when NumWithout == 0<br>
><br>
><br>
> testcase included.<br>
><br>
><br>
> ______________________________<u></u><u></u>_________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailm<u></u>an/listinfo/llvmdev</a><br>
><br>
<br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</blockquote></div></div></blockquote></div></div>