<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - RLEV does not optimize loop"
href="https://llvm.org/bugs/show_bug.cgi?id=26638">26638</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>RLEV does not optimize loop
</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>normal
</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>sanjoy@playingwithpointers.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I'd expect -indvars to RLEV away `%count.0.lcssa` in the loop below:
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"
define i32 @count_odds(i32 %lim) {
entry:
%cmp8 = icmp sgt i32 %lim, 0
br i1 %cmp8, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.body, %entry
%count.0.lcssa = phi i32 [ 0, %entry ], [ %count.0.inc, %for.body ]
ret i32 %count.0.lcssa
for.body: ; preds = %entry, %for.body
%i.010 = phi i32 [ %inc2, %for.body ], [ 0, %entry ]
%count.09 = phi i32 [ %count.0.inc, %for.body ], [ 0, %entry ]
%and = and i32 %i.010, 1
%count.0.inc = add i32 %and, %count.09
%inc2 = add i32 %i.010, 1
%exitcond = icmp eq i32 %inc2, %lim
br i1 %exitcond, label %for.cond.cleanup, label %for.body
}
In C, this roughly corresponds to
int count_odds(int lim) {
int count = 0;
for (int i = 0; i < lim; i++)
if ((i & 1) == 1)
count++;
return count;
}
(except that I've removed the nsw and nuws)</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>