[LLVMdev] How to identify the first BB in a loop of non-constant trip count?
Bo Wu
bwu at cs.wm.edu
Mon Jan 23 07:37:18 PST 2012
Hi,
The compilation of the following code
void f(int *a, int b[], int n)
{
int i;
for(i=0; i< n; ++i)
a[i] = b[i];
}
gives the IR:
define void @f(i32* nocapture %a, i32* nocapture %b, i32 %n) nounwind {
%1 = icmp sgt i32 %n, 0
br i1 %1, label %.lr.ph, label %._crit_edge
.lr.ph: ; preds = %0
%tmp = zext i32 %n to i64
br label %2
; <label>:2 ; preds = %2, %.lr.ph
%indvar = phi i64 [ 0, %.lr.ph ], [ %indvar.next, %2 ]
%scevgep = getelementptr i32* %a, i64 %indvar
%scevgep2 = getelementptr i32* %b, i64 %indvar
%3 = load i32* %scevgep2, align 4, !tbaa !0
store i32 %3, i32* %scevgep, align 4, !tbaa !0
%indvar.next = add i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %tmp
br i1 %exitcond, label %._crit_edge, label %2
._crit_edge: ; preds = %2, %0
ret void
}
My question is how can I identify the first BB in a loop of non-constant
trip count? In this example, it is the first BB of the function, which
decides whether going to the loop body or not. What's the name of such BBs?
For example, some BBs have the name preheader or header, ...
Bo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120123/14671055/attachment.html>
More information about the llvm-dev
mailing list