<div dir="ltr">If its the conversion I know of, try  -simplifycfg-merge-cond-stores=false</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Mon, Apr 24, 2017 at 3:34 AM, Micha Reiser via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hy everyone<br>
<br>
I'm writing an LLVM frontend that compiles a subset of TypeScript to WebAssembly using the new experimental Web Assembly Target. and LLVM opt to optimize the output. As part of my work, I compare the runtime of the generated Web Assembly implementation to the plain JavaScript version.  During this evaluation, I noticed that LLVM opt converts if statements with a store to a select statement to reduce the number of branches. E.g., the following<br>
<br>
for (let j = i; j < points.length; j += 2) {<br>
  const distance = euclideanDistance(currentX, currentY, points[j], points[j+1]);<br>
<br>
  if (distance < shortestDistance) {<br>
    shortestDistance = distance;<br>
    nearestIndex = j;<br>
  }<br>
}<br>
<br>
collapses to (the if is removed)<br>
<br>
for (let j = i; j < points.length; j += 2) {<br>
  const distance = euclideanDistance(currentX, currentY, points[j], points[j+1]);<br>
<br>
  let shorter = distance < shortestDistance;<br>
  shortestDistance shorter ? distance : shortestDistance;<br>
  nearestIndex = shorter ? j : nearestIndex;<br>
}<br>
<br>
My benchmarks show that this optimization has a negative impact on performance (at least if there are two or more assignments). Therefore, I would like to disable this optimization pass or at least tune it only to collapse the if statement if there is only a single assignment.<br>
<br>
Is there a way to disable this optimization pass or fine tune it to define how many statements are allowed to be collapsed?<br>
<br>
Thank you  very much,<br>
Micha<br>
<br>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>