This is the mail archive of the gcc-patches@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: [RFC] Enable saliasing for structs with arrays


Hello,

> > this does not suck, this is plain wrong.  TMR_SYMBOL has absolutely
> > nothing to do with alias analysis.  The only place from where alias
> > information for TARGET_MEM_REFs can be taken is TMR_TAG; and
> > unfortunately the way alias information for subvars is represented
> > is more or less incompatible with the way alias info is represented
> > for all other types of memory references, which makes it hard to adapt.
> 
> Ok, here's what I have now - it miscompiles stage2 though, testing with
> the stage1 compiler is in progress.  Maybe you can see something
> obviously wrong with my approach.

>   static tree
> ! get_ref_tag (tree ref_)
>   {
> !   tree var = get_base_address (ref_);
> !   unsigned HOST_WIDE_INT offset, size;
> !   tree ref = okay_component_ref_for_subvars (ref_, &offset, &size);
>     tree tag;
>   
> +   if (ref)
> +     {
> +       subvar_t svars = get_subvars_for_var (ref);
> +       subvar_t sv;
> +       for (sv = svars; sv; sv = sv->next)
> +         {
> +           bool exact;
> +           if (overlap_subvar (offset, size, sv, &exact)
> + 	      && exact)
> + 	    return sv->var;
> +         }
> +     }

it may happen that more than one subvar must be taken into account here.
The code as it is here might be more or less OK, because you check
exact, but I am not really sure about it -- is this correct with unions?
But in any case you may happen to lose alias info here, which I do not
want to happen.

>     if (!var)
>       return NULL_TREE;
>   
> *************** rewrite_use (struct ivopts_data *data,
> *** 5745,5750 ****
> --- 5760,5766 ----
>   	gcc_unreachable ();
>       }
>     update_stmt (use->stmt);
> +   mark_new_vars_to_rename (use->stmt);
>   }

This should not be necessary with the correct approach -- the alias info
should be completely preserved, thus the virtual operands of the
statement should not change at all.

> Index: tree-ssa-operands.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
> retrieving revision 2.97
> diff -c -3 -p -r2.97 tree-ssa-operands.c
> *** tree-ssa-operands.c	20 Jul 2005 01:18:26 -0000	2.97
> --- tree-ssa-operands.c	21 Jul 2005 12:24:35 -0000
> *************** get_tmr_operands (tree stmt, tree expr, 
> *** 1698,1704 ****
>       }
>   
>     if (tag)
> !     add_stmt_operand (&tag, stmt_ann (stmt), flags);
>     else
>       /* Something weird, so ensure that we will be careful.  */
>       stmt_ann (stmt)->has_volatile_ops = true;
> --- 1698,1709 ----
>       }
>   
>     if (tag)
> !     {
> !       if (TREE_CODE (tag) == SSA_NAME)
> !         add_stmt_operand (&tag, stmt_ann (stmt), flags);
> !       else
> !         get_expr_operands (stmt, &tag, flags);
> !     }
>     else
>       /* Something weird, so ensure that we will be careful.  */
>       stmt_ann (stmt)->has_volatile_ops = true;

Why is this change necessary?  And, how it can happen that TMR_TAG is an
SSA name?

Zdenek


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