Hi,
How do I access the loop variables in a loop.
for(i = 0; i < N; i++)
for(j = 0; j < M; j++)
A[i][j+k] = i + j;
Is there anyway for me to know that in A[i][j+k], i & j are loop variables
whereas k is not!
Regards,
Prasenjit Chakraborty
Performance Modeling and Analysis
IBM Systems & Technology Lab
Hi, You can use the getInductionVariable() on each loop,and maintain a smallvect of all induction variables that you have come across. Also remember to run some passes to hoist loop independent entities out of the loop. Cheers Dhruv On Mon, Oct 12, 2009 at 6:46 AM, Prasenjit Chakraborty <cprasenj at in.ibm.com>wrote:> > Hi, > How do I access the loop variables in a loop. > > for(i = 0; i < N; i++) > for(j = 0; j < M; j++) > A[i][j+k] = i + j; > > Is there anyway for me to know that in A[i][j+k], i & j are loop variables > whereas k is not! > > Regards, > > Prasenjit Chakraborty > Performance Modeling and Analysis > IBM Systems & Technology Lab > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- School of Electrical and Computer Engineering Georgia Institute of Technology (M) +1 770 827 9264 Personal Email : choudharydhruv at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091012/ad01c59a/attachment.html>
On Oct 12, 2009, at 3:46 AM, Prasenjit Chakraborty wrote:> > Hi, > How do I access the loop variables in a loop. > > for(i = 0; i < N; i++) > for(j = 0; j < M; j++) > A[i][j+k] = i + j; > > Is there anyway for me to know that in A[i][j+k], i & j are loop > variables > whereas k is not!The ScalarEvolution analysis can help here. If you've already identified i, j, and k yourself, you can call getSCEV on them and use the isLoopInvariant and hasComputableLoopEvolution member functions. ScalarEvolution doesn't yet help in identifying the indices used in each dimension of a multi-dimensional array reference in the way that a traditional dependence analysis would want to see them, though that's a future goal. Dan
I have not identified i, j or k. The whole point is I want to know that
there are variables i & j which are loop variables.
Calling getInductionVariab;le() returns NULL, reason being I don't see any
PHINode in the loop.
Regards,
Prasenjit Chakraborty
Performance Modeling and Analysis
IBM Systems & Technology Lab
Dan Gohman
<gohman at apple.com
> To
Prasenjit
10/12/2009 11:13 Chakraborty/India/IBM at IBMIN
PM cc
llvmdev at cs.uiuc.edu
Subject
Re: [LLVMdev] Accessing Loop
Variables
On Oct 12, 2009, at 3:46 AM, Prasenjit Chakraborty wrote:
>
> Hi,
> How do I access the loop variables in a loop.
>
> for(i = 0; i < N; i++)
> for(j = 0; j < M; j++)
> A[i][j+k] = i + j;
>
> Is there anyway for me to know that in A[i][j+k], i & j are loop
> variables
> whereas k is not!
The ScalarEvolution analysis can help here. If you've already identified
i, j, and k yourself, you can call getSCEV on them and use the
isLoopInvariant and hasComputableLoopEvolution member functions.
ScalarEvolution doesn't yet help in identifying the indices used in
each dimension of a multi-dimensional array reference in the way that a
traditional dependence analysis would want to see them, though that's
a future goal.
Dan