[llvm-bugs] [Bug 26638] New: RLEV does not optimize loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 16 11:05:25 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26638
Bug ID: 26638
Summary: RLEV does not optimize loop
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: sanjoy at playingwithpointers.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160216/9a76d001/attachment.html>
More information about the llvm-bugs
mailing list