[LLVMdev] Accessing Loop Variables
Dan Gohman
gohman at apple.com
Mon Oct 12 10:43:06 PDT 2009
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
More information about the llvm-dev
mailing list