<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Loop with early continue does not produce same IR as loop without"
href="https://bugs.llvm.org/show_bug.cgi?id=45255">45255</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop with early continue does not produce same IR as loop without
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>Matthew.Arsenault@amd.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23260" name="attach_23260" title="Testcase with early continue">attachment 23260</a> <a href="attachment.cgi?id=23260&action=edit" title="Testcase with early continue">[details]</a></span>
Testcase with early continue
This testcase has two versions of a program with a slightly different loop
structure.
The first testcase (extract.while.ll) looks like this:
while (I < N) {
if (foo()) {
++I;
continue;
}
bar();
++I;
}
The second version (extract.while.no.continue.ll looks like this:
while (I < N) {
if (!foo()) {
bar();
}
++I;
}
I would expect these to optimize to the same IR, but they do not. The form with
the continue ends up codegenning to something worse, and ends up about 50%
slower on AMDGPU.
Note the attached IR has already gone through the optimizer once, and the
second form was rotated and has the preheader. I've been operating under the
assumption I should be able to just run -loop-rotate on the first form to get
equivalent IR as the second form.
The relevant part of the testcase is while.body.i/if.then320.i. if.then320.i is
the continue block in the first version.
I'm able to get opt -loop-rotate to rotate this loop by increasing
-rotation-max-header-size to at least 18, and hacking
profitableToRotateLoopExitingLatch to always return true</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>