[llvm-dev] Detecting "openmp" loop and its original bounds.

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[llvm-dev] Detecting "openmp" loop and its original bounds.

Eric Christopher via llvm-dev

I am trying to do a transformation pass in "opt".
#pragma omp parallel for
          for (int j=0; j<1000000; j++)
                b[j] = a[j]*scalar;
 For the above  loop under -fopenmp:
1.  How to check if the loop I am working is a parallel loop (i.e. discover the       "openmp" hint)
      I tired  Loop->isAnnotatedParallel(),  but  it is returning false. 
2.   Is there some way to discover the original bounds of the loop?
      I could see the original bounds are passed at the start of the "@.omp_outlined" function.
     %0 = bitcast i32* %.omp.lb to i8*
     call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0) #4
     store i32 0, i32* %.omp.lb, align 4, !tbaa !7  <== lower bound 
     %1 = bitcast i32* %.omp.ub to i8*
     call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %1) #4
     store i32 999999, i32* %.omp.ub, align 4, !tbaa !7 <== upper bound.

    Now the loop is 
    omp.inner.for.body:                               ; preds = %omp.inner.for.body.preheader, %omp.inner.for.body
    %indvars.iv = phi i64 [ %8, %omp.inner.for.body.preheader ], [ %indvars.iv.next, %omp.inner.for.body ]
    %cmp1 = icmp slt i64 %indvars.iv, %9
    br i1 %cmp1, label %omp.inner.for.body, label %omp.loop.exit 

%8  is lower bound 
%9 is maximum of upper bound and 999999.

   I could do a backward walk and figure out what the bounds are initially set to? 
   Are there a better ways for doing it example using SCEV ?

LLVM Developers mailing list
[hidden email]