<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">LGTM. Nice find.<br>
<br>
For anyone curious, this case applies to PRE, but not LoadPRE. We
do handle full redundancy for loads today.<br>
<br>
Philip<br>
<br>
On 01/28/2015 03:15 PM, Daniel Berlin wrote:<br>
</div>
<blockquote
cite="mid:CAF4BwTXvSCNQnaxvBwHbNXcgy8+KF+aqag8jw6SOqZV+Jk0Bqw@mail.gmail.com"
type="cite">
<div dir="ltr">Current PRE tries to not increase code size.
<div>It does this with a check whether or not the number of
places it would have to insert is 1 or not.</div>
<div><br>
</div>
<div>The problem with this is that the answer could also be "we
have to insert in zero places" in the case it's available in
all predecessors.</div>
<div> :)</div>
<div><br>
</div>
<div>Normal dominator based elimination in GVN will not catch
these cases because the branches do not dominate the merge
point.</div>
<div><br>
</div>
<div>A simple example</div>
<div><span style="font-size:13.1999998092651px">int c;</span></div>
<div>
<div>int d;</div>
<div>int pre(int foo, int a, int b)</div>
<div>{</div>
<div><span style="font-size:13.1999998092651px"> int g;</span></div>
<div><span style="font-size:13.1999998092651px"> if (foo)
{</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> c
= a+b;</div>
<div> } <span style="font-size:13.1999998092651px">else </span><span
style="font-size:13.1999998092651px">{</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> d
= a+ b;</div>
<div> }</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>g
= a+b;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return
g;</div>
<div>}</div>
</div>
<div><br>
</div>
<div>Without this patch, PRE (and GVN) will not eliminate g =
a+b.</div>
<div>With this patch, PRE will create phi(c, d) and eliminate g
= a + b.</div>
<div><br>
</div>
<div>(It is tremendously more difficult to make current GVN
understand the problem, and GCC solves this the same way i'm
about to).</div>
<div><br>
</div>
<div>The patch looks large because of code movement, but it
basically all boils down to changing this check:</div>
<div><br>
</div>
<div>if (NumWithout != 1 || NumWith == 0)</div>
<div><br>
</div>
<div>to</div>
<div>if (NumWithout > 1 || NumWith == 0)</div>
<div><br>
</div>
<div>and skipping insertion when NumWithout == 0</div>
<div><br>
</div>
<div>testcase included.</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>