[LLVMbugs] [Bug 8882] New: Poor scalar optimization loses trip count info
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jan 1 14:40:10 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=8882
Summary: Poor scalar optimization loses trip count info
Product: libraries
Version: 1.0
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clattner at apple.com
CC: llvmbugs at cs.uiuc.edu
We compile this:
template <typename Iterator, typename T>
void fill(Iterator first, Iterator last, T value) {
while (first != last) *first++ = value;
}
int X[1000];
void foo() {
fill(X, X+1000, 0);
}
with: clang t.cpp -S -o - -emit-llvm -O3
into:
while.body.i: ; preds = %while.body.i,
%entry
%indvar.i = phi i64 [ %tmp.i, %while.body.i ], [ 0, %entry ]
%tmp.i = add i64 %indvar.i, 1
%first.addr.05.i = getelementptr [1000 x i32]* @X, i64 0, i64 %indvar.i
store i32 0, i32* %first.addr.05.i, align 4, !tbaa !0
%ptrincdec.i.idx.mask = and i64 %tmp.i, 4611686018427387903
%cmp.i = icmp eq i64 %ptrincdec.i.idx.mask, 1000
br i1 %cmp.i, label %_Z4fillIPiiEvT_S1_T0_.exit, label %while.body.i
This loop executes exactly 1000 times. This appears to be being pessimized by
the -indvars pass, as can be seen by:
clang t.cpp -S -o - -emit-llvm -O0 | opt -mem2reg -S -inline -loop-rotate
-instcombine -indvars
which introduces the 'and'. The and is not needed because the GEP can't wrap
around.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list