This is the mail archive of the 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]

[PATCH] Let completely_scalarize_record creates access expressions on its own


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?



2010-07-29  Martin Jambor  <>

	* 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.  */
-	  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 ");

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