This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Identifying a block copy


On 10/9/07, Pranav Bhandarkar <pranav.bhandarkar@gmail.com> wrote:
> Hi,
> consider the following code,
>
> struct x { int a; int b; int c; int d; int e[120];};
> struct x *a, *b;
> void foo ( )
> {
>     *a = *b;
> }
>
> Now for the stmt int the function foo a memcpy will be generated.
> However, this can be tail call optimized. My aim is to identify such
> opportunities in find_tail_calls in tree-tailcall.c. However, for the
> stmt
>
> *a.0_1 ={v} *b.1_2;
>
> var_can_have_subvars return zero for  *a.0_1 . But  a.0_1 is pointer
> to a structure and *a.0_1 is a structure and therefore can have
> subvars.

No, it's not a named location.

>
> The comment for var_can_have_subvars says
> /* Return true if V is a tree that we can have subvars for.
>    Normally, this is any aggregate type.  Also complex
>    types which are not gimple registers can have subvars.  */

s/tree/variable/
I'll change the comment.

>
> IMHO, var_can_have_subvars for the above case should return true, but
> it doesnt because it fails the following test in var_can_have_subvars.
>   /* Non decls or memory tags can never have subvars.  */
>   if (!DECL_P (v) || MTAG_P (v))
>     return false;
>
> Am I missing something here ?
Yes
we do not create subvars for non-named memory locations.  IE random
pointer dereferences.

This is mainly because it would require a lot of time and memory in
the compiler.

It was done because most optimizers rely solely on vdef/vuses, instead
of further disambiguating the memory dependence chains.


In any case, it's not clear why you care about subvars at all here.
If you want to identify block copies, simply look for assignments
between AGGREGATE_TYPE_P trees.

> TIA,
> Pranav
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]