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: [PATCH] Let completely_scalarize_record creates access expressions on its own


On Mon, 2 Aug 2010, Martin Jambor wrote:

> Hi,
> 
> this is a first patch in a small series to make build_ref_for offset
> build a MEM_REF instead of the elaborate recursive algorithm we have
> there today (and as a by-product, fix PR44972).  
> 
> This patch addresses the problem that we do not want MEM_REFs in
> DECL_DEBUG_EXPRs and so cannot really store such references to
> access->expr fields.  Thus instead of relying on build_ref_for_offset
> to create the references for us, I taught the function to easily
> create them itself.
> 
> BTW, I'm afraid that we'll need to retain the current elaborate
> build_ref_for_offset, perhaps under a different name, to create these
> references in create_artificial_child_access.
> 
> Also, for the currently WIP re-implementation of build_ref_for_offset
> I simply need it for bit-fields :-) And last but not least, this is a
> much more straight-forward way of doing things and so perhaps also
> worht to have on its own.  Bootstrapped and tested on x86_85-linux, OK
> for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 2010-07-29  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (completely_scalarize_record): New parameter REF, create
> 	its own access->expr intead of using build_ref_for_offset.
> 
> Index: mine/gcc/tree-sra.c
> ===================================================================
> --- mine.orig/gcc/tree-sra.c
> +++ mine/gcc/tree-sra.c
> @@ -843,10 +843,12 @@ type_consists_of_records_p (tree type)
>  /* Create total_scalarization accesses for all scalar type fields in DECL that
>     must be of a RECORD_TYPE conforming to type_consists_of_records_p.  BASE
>     must be the top-most VAR_DECL representing the variable, OFFSET must be the
> -   offset of DECL within BASE.  */
> +   offset of DECL within BASE.  REF must be the memory reference expression for
> +   the given decl.  */
>  
>  static void
> -completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset)
> +completely_scalarize_record (tree base, tree decl, HOST_WIDE_INT offset,
> +			     tree ref)
>  {
>    tree fld, decl_type = TREE_TYPE (decl);
>  
> @@ -855,28 +857,23 @@ completely_scalarize_record (tree base,
>        {
>  	HOST_WIDE_INT pos = offset + int_bit_position (fld);
>  	tree ft = TREE_TYPE (fld);
> +	tree nref = build3 (COMPONENT_REF, TREE_TYPE (fld), ref, fld,
> +			    NULL_TREE);
>  
>  	if (is_gimple_reg_type (ft))
>  	  {
>  	    struct access *access;
>  	    HOST_WIDE_INT size;
> -	    tree expr;
> -	    bool ok;
>  
>  	    size = tree_low_cst (DECL_SIZE (fld), 1);
> -	    expr = base;
> -	    ok = build_ref_for_offset (&expr, TREE_TYPE (base), pos,
> -				       ft, false);
> -	    gcc_assert (ok);
> -
>  	    access = create_access_1 (base, pos, size);
> -	    access->expr = expr;
> +	    access->expr = nref;
>  	    access->type = ft;
>  	    access->total_scalarization = 1;
>  	    /* Accesses for intraprocedural SRA can have their stmt NULL.  */
>  	  }
>  	else
> -	  completely_scalarize_record (base, fld, pos);
> +	  completely_scalarize_record (base, fld, pos, nref);
>        }
>  }
>  
> @@ -2067,7 +2064,7 @@ analyze_all_variable_accesses (void)
>  		<= max_total_scalarization_size)
>  	    && type_consists_of_records_p (TREE_TYPE (var)))
>  	  {
> -	    completely_scalarize_record (var, var, 0);
> +	    completely_scalarize_record (var, var, 0, var);
>  	    if (dump_file && (dump_flags & TDF_DETAILS))
>  	      {
>  		fprintf (dump_file, "Will attempt to totally scalarize ");
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


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