<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:florian_hahn@apple.com" title="Florian Hahn <florian_hahn@apple.com>"> <span class="fn">Florian Hahn</span></a>
</span> changed
<a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - LLVM fails to unroll multi-exit loops with multiple exiting blocks jumping to the same exit block and runtime trip count"
href="https://bugs.llvm.org/show_bug.cgi?id=27360">bug 27360</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>RESOLVED
</td>
<td>REOPENED
</td>
</tr>
<tr>
<td style="text-align:right;">Summary</td>
<td>LLVM cannot unroll loops with multiple exits
</td>
<td>LLVM fails to unroll multi-exit loops with multiple exiting blocks jumping to the same exit block and runtime trip count
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>FIXED
</td>
<td>---
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - LLVM fails to unroll multi-exit loops with multiple exiting blocks jumping to the same exit block and runtime trip count"
href="https://bugs.llvm.org/show_bug.cgi?id=27360#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - LLVM fails to unroll multi-exit loops with multiple exiting blocks jumping to the same exit block and runtime trip count"
href="https://bugs.llvm.org/show_bug.cgi?id=27360">bug 27360</a>
from <span class="vcard"><a class="email" href="mailto:florian_hahn@apple.com" title="Florian Hahn <florian_hahn@apple.com>"> <span class="fn">Florian Hahn</span></a>
</span></b>
<pre>Ok, turns out that without the pragma, multi-exit unrolling is not happing, due
to a TODO in LoopUnrollRuntime.cpp. I am re-opening the issue to address that:
// TODO: Support multiple exiting blocks jumping to the `LatchExit` when
// UnrollRuntimeMultiExit is true. This will need updating the logic in
// connectEpilog/connectProlog.
if (!LatchExit->getSinglePredecessor()) {
Below the IR for the example at hand. @multi_exit_runtime_trip_count is not
unrolled even with -unroll-runtime -unroll-runtime-multi-exit, due to the TODO.
@unroll_latch_count_known is unrolled with -unroll-allow-partial.
define i1 @multi_exit_runtime_trip_count(i32 %i, i32* %m) {
entry:
%0 = sext i32 %i to i64
br label %while.cond
while.cond: ; preds = %while.body, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %while.body ], [ %0, %entry ]
%w.0.in = getelementptr inbounds i32, i32* %m, i64 %indvars.iv
%w.0 = load i32, i32* %w.0.in, align 4
%cmp = icmp eq i32 %w.0, 0
br i1 %cmp, label %while.body, label %cleanup
while.body: ; preds = %while.cond
%indvars.iv.next = add nsw i64 %indvars.iv, -1
%cmp1 = icmp slt i64 %indvars.iv, 1
br i1 %cmp1, label %cleanup, label %while.cond
cleanup: ; preds = %while.cond,
%while.body
%retval.0 = phi i1 [ false, %while.body ], [ true, %while.cond ]
ret i1 %retval.0
}
define i1 @unroll_latch_count_known(i32 %i, i32* %m) {
entry:
%0 = sext i32 %i to i64
br label %while.cond
while.cond: ; preds = %while.body, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %while.body ], [ 0, %entry ]
%w.0.in = getelementptr inbounds i32, i32* %m, i64 %indvars.iv
%w.0 = load i32, i32* %w.0.in, align 4
%cmp = icmp eq i32 %w.0, 0
br i1 %cmp, label %while.body, label %cleanup
while.body: ; preds = %while.cond
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%cmp1 = icmp eq i64 %indvars.iv, 999
br i1 %cmp1, label %cleanup, label %while.cond
cleanup: ; preds = %while.cond,
%while.body
%retval.0 = phi i1 [ false, %while.body ], [ true, %while.cond ]
ret i1 %retval.0
}</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>