<br><br><div class="gmail_quote">On Tue, Aug 6, 2013 at 1:42 PM, Adve, Vikram Sadanand <span dir="ltr"><<a href="mailto:vadve@illinois.edu" target="_blank">vadve@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div style="word-wrap:break-word">
<blockquote type="cite">Message: 6<br>
Date: Tue, 6 Aug 2013 10:46:19 -0400<br>
From: Chad Rosier <<a href="mailto:chad.rosier@gmail.com" target="_blank">chad.rosier@gmail.com</a>><br>
To: llvmdev <<a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a>><div class="im"><br>
Subject: [LLVMdev] Potential SimplifyCFG optimization;<span style="white-space:pre-wrap">
</span>hammock to<br>
<span style="white-space:pre-wrap"></span>diamond transformation<br></div>
Message-ID:<br>
<span style="white-space:pre-wrap"></span><<a href="mailto:CAMo3wbR6x1wBzb17=GrkERV7kvzx2RdpuheFzyxkQEs3BBvKaw@mail.gmail.com" target="_blank">CAMo3wbR6x1wBzb17=GrkERV7kvzx2RdpuheFzyxkQEs3BBvKaw@mail.gmail.com</a>><br>

Content-Type: text/plain; charset="iso-8859-1"<div class="im"><br>
<br>
All,<br>
I have some code that looks like the following:<br>
<br>
{<br>
 double a, b, c;<br>
 for (...) {<br>
   ...<br>
   a = lots of FP math;<br>
   b = lots of FP math;<br>
   c = lots of FP math;<br>
   if (cond) {<br>
     a = 0.0;<br>
     b = 0.1;<br>
     c = 0.2;<br>
   }<br>
  ...<br>
 }<br>
}<br>
<br>
Could we not convert the hammock into a diamond and move the initial<br>
computation of a, b, and c into the else block.  Something like this:<br>
</div></blockquote>
<div><br>
</div>
I believe what you're proposing would be accomplished by PRE, since the stores to a, b and c are partially redundant, and once those are "placed" by PRE, the FP math would then get placed as you want as well.
<br></div></blockquote><div><br><br>Yes, that makes perfect sense.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">

<div><div><div class="im"><blockquote type="cite"><br>
{<br>
 double a, b, c;<br>
 for (...) {<br>
   ...<br>
   if (cond) {<br>
     a = 0.0;<br>
     b = 0.1;<br>
     c = 0.2;<br>
   } else {<br>
     a = lots of FP math;<br>
     b = lots of FP math;<br>
     c = lots of FP math;<br>
   }<br>
  ...<br>
 }<br>
}<br>
<br>
Does a similar optimization exist? </blockquote>
<div><br>
</div>
</div><div>SSAPRE existed in LLVM but has been removed.  PRE is one of those optimizations that are simply more efficient and also sometimes more effective as a bitvector dataflow optimization than as an SSA algorithm.</div>
<div class="im">
</div></div></div></div></blockquote><div><br>Good to know.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">
<div><div><div class="im">
<br>
<blockquote type="cite"> If not, would the SimplifyCFG pass be<br>
an appropriate home for such an optimization?<br>
</blockquote>
<div><br>
</div>
</div><div>If done there, it is likely to only handle special cases like the above.  My guess is that it is better done as a code motion pass than a SimplifyCFG extension.</div></div></div></div></blockquote><div><br>Thanks for the feedback, Prof. Vikram.  You have been very helpful.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div><blockquote type="cite">
Chad<br>
</blockquote>
<div><br>
</div>
<div><br>
</div>
<div>
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Calibri;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Calibri;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Calibri;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Calibri;word-wrap:break-word;word-spacing:0px">

<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Calibri;word-wrap:break-word;word-spacing:0px">

<div>
<div><span style="font-family:monospace">--Vikram Adve</span><br style="font-family:monospace">
<span style="font-family:monospace">Professor, Department of Computer Science</span><br style="font-family:monospace">
<span style="font-family:monospace">University of Illinois at Urbana-Champaign</span><br style="font-family:monospace">
<span style="font-family:monospace"><a href="mailto:vadve@illinois.edu" target="_blank">vadve@illinois.edu</a></span></div>
<div><span style="font-family:monospace"><a href="http://llvm.org" target="_blank">http://llvm.org</a></span></div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">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/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br>