[llvm-dev] SCEV cannot compute the trip count of Simple loop
Rai, Deepali via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 16 00:31:11 PDT 2016
Hi All,
I am trying to unroll the below loop, but couldn't as SCEV returns TripCount as 0.
void foo(int x) {
int p, i = 1;
int mat[6][6][6];
for (p = x+3 ; p<= x+6 ;p++)
mat[x][p][i] = mat[x][p][i] + 5;
}
For a quick reference I have added the generated IR compiled with clang using -O3.
Please let me know if this is an known issue in SCEV or I am missing something here ?
; Function Attrs: nounwind readnone uwtable
define void @_Z3fooi(i32 %x) local_unnamed_addr #0 {
entry:
%mat = alloca [6 x [6 x [6 x i32]]], align 16
%0 = bitcast [6 x [6 x [6 x i32]]]* %mat to i8*
call void @llvm.lifetime.start(i64 864, i8* %0) #2
%add = add nsw i32 %x, 3
%add1 = add nsw i32 %x, 6
%idxprom3 = sext i32 %x to i64
%1 = sext i32 %add to i64
%2 = sext i32 %add1 to i64
br label %for.body
for.body: ; preds = %for.body, %entry
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %1, %entry ]
%arrayidx5 = getelementptr inbounds [6 x [6 x [6 x i32]]], [6 x [6 x [6 x i32]]]* %mat, i64 0, i64 %idxprom3, i64 %indvars.iv, i64 1
%3 = load i32, i32* %arrayidx5, align 4, !tbaa !1
%add6 = add nsw i32 %3, 5
store i32 %add6, i32* %arrayidx5, align 4, !tbaa !1
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%cmp = icmp slt i64 %indvars.iv, %2
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
call void @llvm.lifetime.end(i64 864, i8* nonnull %0) #2
ret void
}
Thanks,
Deepali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160916/56745a14/attachment.html>
More information about the llvm-dev
mailing list