[PATCH] Change VECTOR_CST representation from TREE_LIST to TREE_VEC-like

Richard Guenther rguenther@suse.de
Thu Mar 15 13:02:00 GMT 2012


On Thu, 15 Mar 2012, Richard Guenther wrote:

> 
> This removes the use of TREE_LISTs for VECTOR_CSTs and instead employs
> a similar way of storing elements as TREE_VECs.  I copied the
> macro interface bits of the CONSTRUCTOR accesses and did a 1:1 transform
> at most places to not let refactoring errors creep in (well, where 
> possible).  I'm not sure if it's worth omitting the explicit length
> field in favor of using that of the type - at least we are getting
> consistency (no implicit zero elements) here for free.
> 
> Bootstrap and regtest on x86_64-unknown-linux-gnu running.  I cannot
> test sparc apart from compiling a cc1, which works.
> 
> Ok for the c-common and sparc bits?  Any other comments?

Bootstrapped ok on x86_64-unknown-linux-gnu.  Incremental patch to
fix issues revealed by testing below.

Richard.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c.orig	2012-03-15 14:02:31.000000000 +0100
+++ gcc/tree.c	2012-03-15 13:51:27.000000000 +0100
@@ -1328,6 +1328,7 @@ build_vector_stat (tree type, tree *vals
   v = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
   TREE_SET_CODE (v, VECTOR_CST);
+  TREE_CONSTANT (v) = 1;
   TREE_TYPE (v) = type;
 
   /* Iterate through elements and check for overflow.  */
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c.orig	2012-03-15 14:02:31.000000000 +0100
+++ gcc/varasm.c	2012-03-15 13:59:37.000000000 +0100
@@ -4596,8 +4596,8 @@ output_constant (tree exp, unsigned HOST
 
 	    elt_size = GET_MODE_SIZE (inner);
 
-	    thissize = 0;
 	    output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align);
+	    thissize = elt_size;
 	    for (i = 1; i < VECTOR_CST_NELTS (exp); ++i)
 	      {
 		output_constant (VECTOR_CST_ELT (exp, i), elt_size, nalign);



More information about the Gcc-patches mailing list