* identifying indirect references in a loop
@ 2009-12-11 4:16 Aravinda
2009-12-11 11:05 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Aravinda @ 2009-12-11 4:16 UTC (permalink / raw)
To: gcc
Hi,
Im trying to identify all indirect references in a loop so that, after
this analysis, I have a list of tree_nodes of pointer_type that are
dereferenced in a loop along with their step size, if any.
E.g.
while(i++ < n)
{
*(p+i);
}
I want to get the pointer_type_node for 'p' and identify the step size
as '1', since 'i' has a step size of 1.
I am able to identify 'INDIRECT_REF' nodes in the loop. But since
these are generally the expression_temporaries, I will not get the
tree_node for 'p'. But I believe INDIRECT_REF is an expression who's
arg0 is an SSA_NAME node from which I will be able to use the
SSA_NAME_DEF_STMT to ultimately reach the tree_node for 'p'.
But I dont know how to get the SSA_NAME node from the given
INDIRECT_REF. Could someone please point out how to do this.
Also, I find it very difficult to know how the tree_nodes and types
are contained one within the other. Is there a general technique by
which I can know when a tree node will be nested within another and
how to retrieve them ?
Thanks,
Aravinda
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: identifying indirect references in a loop
2009-12-11 4:16 identifying indirect references in a loop Aravinda
@ 2009-12-11 11:05 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2009-12-11 11:05 UTC (permalink / raw)
To: Aravinda; +Cc: gcc
On Fri, Dec 11, 2009 at 5:16 AM, Aravinda <aravindakidambi@gmail.com> wrote:
> Hi,
>
> Im trying to identify all indirect references in a loop so that, after
> this analysis, I have a list of tree_nodes of pointer_type that are
> dereferenced in a loop along with their step size, if any.
>
> E.g.
> while(i++ < n)
> {
> *(p+i);
> }
>
> I want to get the pointer_type_node for 'p' and identify the step size
> as '1', since 'i' has a step size of 1.
>
> I am able to identify 'INDIRECT_REF' nodes in the loop. But since
> these are generally the expression_temporaries, I will not get the
> tree_node for 'p'. But I believe INDIRECT_REF is an expression who's
> arg0 is an SSA_NAME node from which I will be able to use the
> SSA_NAME_DEF_STMT to ultimately reach the tree_node for 'p'.
>
> But I dont know how to get the SSA_NAME node from the given
> INDIRECT_REF. Could someone please point out how to do this.
>
> Also, I find it very difficult to know how the tree_nodes and types
> are contained one within the other. Is there a general technique by
> which I can know when a tree node will be nested within another and
> how to retrieve them ?
Look into the tree.def file. Operands can be retrieved with the
TREE_OPERAND macro (see tree.h). So if you have an
INDIRECT_REF expression tree node you can get the
variable or SSA_NAME that is dereferenced using TREE_OPERAND (e, 0)
if e is the INDIRECT_REF expression tree. The pointer type
is then simply TREE_TYPE of that operand.
Btw, I think you want to use the existing data dependence analysis
which provides you with a list of data references in a loop.
See tree-data-ref.[ch].
Richard.
> Thanks,
> Aravinda
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-12-11 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-11 4:16 identifying indirect references in a loop Aravinda
2009-12-11 11:05 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).