[llvm-dev] Dependence analysis - missing loop-carried dependencies?

Tobias Grosser via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 9 06:04:40 PDT 2017


On Wed, Aug 9, 2017, at 14:33, Shaun Steenkamp via llvm-dev wrote:
> On 3 August 2017 at 15:57, Shaun Steenkamp <shauncs.s at gmail.com> wrote:
> > I'm trying to do some (loop-carried) dependence analysis using LLVM, but
> > I'm confused by the results I'm getting. For example, consider this simple
> > C program:
> > int main(){
> >   for (int i = 0; i < 10; ++i) {
> >   }
> >   return 0;
> > }
> > I would expect that the loop comparison depends on the loop initialisation
> > and the loop update, however I only see a dependence to the loop
> > initialisation.
> >     %3 = load i32, i32* %i, align 4   --->   store i32 0, i32* %i, align 4
> > I don't see a dependence to `store i32 %8, i32* %i, align 4` as I would
> > have expected. Am I misunderstanding the dependence analysis or doing
> > something wrong?
> 
> For the archives (in case someone stumbles upon this via google):
> 
> I was getting confusing results because I foolishly was forgetting to
> run a lot of basic/essential LLVM passes.
> 
> Running with
>   opt -disable-inlining -mem2reg -loop-simplify -loop-rotate
> -simplifycfg -instcombine -indvars
> gave good results for a loop like this:
>   int A[11];
>   for (int i = 0; i < 10; ++i) {
>     A[i+1] = A[i];
>   }
> 
> I have since found that Polly [1] is much more suitable for my needs,
> so I'm now using that instead.

Nice to hear!

Best,
Tobias


More information about the llvm-dev mailing list