[LLVMdev] Is Loop Dependence Analysis Printing Correct Stats?

Roel Jordans r.jordans at tue.nl
Thu Jun 21 02:28:14 PDT 2012


Hi,

Looking at the code in lib/Analysis/LoopDependenceAnalysis.cpp, the 
'dependent'  in your output should be interpreted more like 'possibly 
not independent'.

Only 'dependent' and 'independent' are considered as outputs and 
'dependent' is the general, 'better safe than sorry' response here.

One other point here is that the -lda pass uses results from alias 
analysis. By default opt uses the '-noaa' pass which always provides a 
'may alias' response. To get more sensible results you will have to add 
a more effective alias analysis to your list of passes (e.g. -basic-aa)

Cheers,
  Roel

On 20/06/12 23:33, Arnamoy Bhattacharyya wrote:
> Hi;
>
> I was playing with the -lda pass of LLVM on the following program-
>
> #include <stdio.h>
> void main()
> {
> int a[10];
> int i;
> for(i = 0; i < 4; i ++)
> {
> a[i] = a[i-1]+1;
> }
> }
>
> I run the following commands -
>
> clang a.c -emit-llvm -S
> opt -analyze -stats -lda a.s
>
> The output is -
>
> Printing analysis 'Loop Dependence Analysis':
> Loop at depth 1, header block: %for.cond
>    Load/store instructions: 7
> 0:   %0 = load i32* %i, align 4
> 1:   %4 = load i32* %i, align 4
> 2:   store i32 %inc, i32* %i, align 4
> 3:   %1 = load i32* %i, align 4
> 4:   %2 = load i32* %arrayidx, align 4
> 5:   %3 = load i32* %i, align 4
> 6:   store i32 %add, i32* %arrayidx1, align 4
>    Pairwise dependence results:
> 0,2: dependent
> 0,6: dependent
> 1,2: dependent
> 1,6: dependent
> 2,3: dependent
> 2,4: dependent
> 2,5: dependent
> 2,6: dependent
> 3,6: dependent
> 4,6: dependent
> 5,6: dependent
> ===-------------------------------------------------------------------------===
>                            ... Statistics Collected ...
> ===-------------------------------------------------------------------------===
>
> 11 lda - Number of dependence queries answered
> 11 lda - Number of distinct dependence pairs analysed
> 11 lda - Number of pairs with unknown accesses
>
> Why do the " Pairwise dependence results:" and the "Statistics
> Collected" differ?  Like first we get 11 "dependent"(must) accesses and
> later it says 11 "unknown" (may) accesses?  Am I doing anything wrong or
> the code seems buggy?
>
> Thanks;
> --
> Arnamoy Bhattacharyya
> Athabasca Hall 143
> Department of Computing Science - University of Alberta
> Edmonton, Alberta, Canada, T6G 2E8
> 587-710-7073



More information about the llvm-dev mailing list