ether zhhb
unread,Apr 22, 2010, 6:26:07 AM4/22/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Eugene Toder, llv...@cs.uiuc.edu
hi,
you could try the getBackedgeTakenCount function of ScalarEvolution.
opt -scalar-evolution -analyze
define void @f(i64* nocapture %a, i64 %N) nounwind {
entry:
%0 = icmp sgt i64 %N, 0 ; <i1> [#uses=1]
br i1 %0, label %bb, label %return
bb: ; preds = %bb, %entry
%1 = phi i64 [ 0, %entry ], [ %2, %bb ] ; <i64> [#uses=3]
%scevgep = getelementptr i64* %a, i64 %1 ; <i64*> [#uses=1]
store i64 %1, i64* %scevgep, align 8
%2 = add nsw i64 %1, 1 ; <i64> [#uses=2]
%exitcond = icmp eq i64 %2, %N ; <i1> [#uses=1]
br i1 %exitcond, label %return, label %bb
return: ; preds = %bb, %entry
ret void
}
Printing analysis 'Scalar Evolution Analysis' for function 'f':
Classifying expressions for: @f
%0 = icmp sgt i64 %N, 0 ; <i1> [#uses=1]
--> %0
%1 = phi i64 [ 0, %entry ], [ %2, %bb ] ; <i64> [#uses=3]
--> {0,+,1}<%bb> Exits: (-1 + %N)
%scevgep = getelementptr i64* %a, i64 %1 ; <i64*> [#uses=1]
--> {%a,+,sizeof(i64)}<%bb> Exits: (((-1 + %N) * sizeof(i64)) + %a)
%2 = add nsw i64 %1, 1 ; <i64> [#uses=2]
--> {1,+,1}<%bb> Exits: %N
%exitcond = icmp eq i64 %2, %N ; <i1> [#uses=1]
--> %exitcond Exits: <<Unknown>>
Determining loop execution counts for: @f
Loop %bb: backedge-taken count is (-1 + %N)
Loop %bb: max backedge-taken count is (-1 + %N)
--best regares
ether