<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<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">chad.rosier@gmail.com</a>><br>
To: llvmdev <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br>
Subject: [LLVMdev] Potential SimplifyCFG optimization;<span class="Apple-tab-span" style="white-space: pre; ">
</span>hammock to<br>
<span class="Apple-tab-span" style="white-space: pre; "></span>diamond transformation<br>
Message-ID:<br>
<span class="Apple-tab-span" style="white-space: pre; "></span><<a href="mailto:CAMo3wbR6x1wBzb17=GrkERV7kvzx2RdpuheFzyxkQEs3BBvKaw@mail.gmail.com">CAMo3wbR6x1wBzb17=GrkERV7kvzx2RdpuheFzyxkQEs3BBvKaw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<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>
</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.
<div>
<div><br>
<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>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><br>
</div>
<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>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><br>
</div>
<div><br>
<blockquote type="cite"><br>
Chad<br>
</blockquote>
<div><br>
</div>
<div><br>
</div>
<div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Calibri; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Calibri; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Calibri; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Calibri; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Calibri; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<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">vadve@illinois.edu</a></span></div>
<div><span style="font-family: monospace; "><a href="http://llvm.org">http://llvm.org</a></span></div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>