[LLVMdev] problem with loopinfo

Wei Jiang wjiang at cs.ucla.edu
Thu Jun 15 15:30:36 PDT 2006


hi, 
    The loopinfo pass failed to recognize the Tripcount of a simple program constructed by me, can you help me to figure out why this happened? Thanks. 
    The C program and corresponding .ll files are shown below. I used llvm1.7 to develop my own pass, and want to use the loop information. 
-Wei

Test.c: 
#include "stdio.h"
#define N 40
void func1() {
  int a[N];
  int i,j;
  for (i=0; i<N; i++) {
      if (i==0)
        a[i] = i*N;
      else
        a[i] = i*i;
  }
}

Test.ll:
void %func1() {
entry:
        %a = alloca [40 x int]          ; <[40 x int]*> [#uses=1]
        br label %no_exit

no_exit:                ; preds = %else, %then, %entry
        %i.0.0 = phi int [ 0, %entry ], [ %inc9, %then ], [ %inc, %else ]       ; <int> [#uses=7]
        %tmp.4 = seteq int %i.0.0, 0            ; <bool> [#uses=1]
        %tmp.7 = getelementptr [40 x int]* %a, int 0, int %i.0.0                ; <int*> [#uses=2]
        br bool %tmp.4, label %then, label %else

then:           ; preds = %no_exit
        %tmp.9 = mul int %i.0.0, 40             ; <int> [#uses=1]
        store int %tmp.9, int* %tmp.7
        %inc9 = add int %i.0.0, 1               ; <int> [#uses=2]
        %tmp.112 = setlt int %inc9, 40          ; <bool> [#uses=1]
        br bool %tmp.112, label %no_exit, label %return

else:           ; preds = %no_exit
        %tmp.14 = mul int %i.0.0, %i.0.0                ; <int> [#uses=1]
        store int %tmp.14, int* %tmp.7
        %inc = add int %i.0.0, 1                ; <int> [#uses=2]
        %tmp.1 = setlt int %inc, 40             ; <bool> [#uses=1]
        br bool %tmp.1, label %no_exit, label %return

return:         ; preds = %else, %then
        ret void
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060615/9c68e252/attachment.html>


More information about the llvm-dev mailing list