2012-04-16 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Apr 2012 13:21:30 +0000 (13:21 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Apr 2012 13:21:30 +0000 (13:21 +0000)
PR middle-end/52977
* tree.h (VECTOR_CST_NELTS): Adjust.
(struct tree_vector): Add explicit length field.
(make_vector_stat): Declare.
(make_vector): Define.
* tree.c (make_vector_stat): New function.
(build_vector_stat): Use it.
* tree-streamer-in.c (streamer_alloc_tree): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186494 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-streamer-in.c
gcc/tree.c
gcc/tree.h

index a1f2b4b..1134191 100644 (file)
@@ -1,3 +1,14 @@
+2012-04-16  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/52977
+       * tree.h (VECTOR_CST_NELTS): Adjust.
+       (struct tree_vector): Add explicit length field.
+       (make_vector_stat): Declare.
+       (make_vector): Define.
+       * tree.c (make_vector_stat): New function.
+       (build_vector_stat): Use it.
+       * tree-streamer-in.c (streamer_alloc_tree): Likewise.
+
 2012-04-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR tree-optimization/52976
index 97c78cd..a38fb47 100644 (file)
@@ -476,10 +476,7 @@ streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
   else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
     {
       HOST_WIDE_INT len = streamer_read_hwi (ib);
-      result = ggc_alloc_zone_cleared_tree_node ((len - 1) * sizeof (tree)
-                                                + sizeof (struct tree_vector),
-                                                &tree_zone);
-      TREE_SET_CODE (result, VECTOR_CST);
+      result = make_vector (len);
     }
   else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
     {
index fcefaab..7a71c24 100644 (file)
@@ -1315,6 +1315,25 @@ cst_and_fits_in_hwi (const_tree x)
          || TREE_INT_CST_HIGH (x) == -1);
 }
 
+/* Build a newly constructed TREE_VEC node of length LEN.  */
+
+tree
+make_vector_stat (unsigned len MEM_STAT_DECL)
+{
+  tree t;
+  unsigned length = (len - 1) * sizeof (tree) + sizeof (struct tree_vector);
+
+  record_node_allocation_statistics (VECTOR_CST, length);
+
+  t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
+
+  TREE_SET_CODE (t, VECTOR_CST);
+  TREE_CONSTANT (t) = 1;
+  VECTOR_CST_NELTS (t) = len;
+
+  return t;
+}
+
 /* Return a new VECTOR_CST node whose type is TYPE and whose values
    are in a list pointed to by VALS.  */
 
@@ -1323,16 +1342,7 @@ build_vector_stat (tree type, tree *vals MEM_STAT_DECL)
 {
   int over = 0;
   unsigned cnt = 0;
-  tree v;
-  int length = ((TYPE_VECTOR_SUBPARTS (type) - 1) * sizeof (tree)
-               + sizeof (struct tree_vector));
-
-  record_node_allocation_statistics (VECTOR_CST, length);
-
-  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 v = make_vector (TYPE_VECTOR_SUBPARTS (type));
   TREE_TYPE (v) = type;
 
   /* Iterate through elements and check for overflow.  */
index 8090176..e8bd858 100644 (file)
@@ -1534,13 +1534,14 @@ struct GTY(()) tree_complex {
 };
 
 /* In a VECTOR_CST node.  */
-#define VECTOR_CST_NELTS(NODE) (TYPE_VECTOR_SUBPARTS (TREE_TYPE (NODE)))
+#define VECTOR_CST_NELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.length)
 #define VECTOR_CST_ELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.elts)
 #define VECTOR_CST_ELT(NODE,IDX) (VECTOR_CST_CHECK (NODE)->vector.elts[IDX])
 
 struct GTY(()) tree_vector {
   struct tree_typed typed;
-  tree GTY ((length ("TYPE_VECTOR_SUBPARTS (TREE_TYPE ((tree)&%h))"))) elts[1];
+  unsigned length;
+  tree GTY ((length ("%h.length"))) elts[1];
 };
 \f
 #include "symtab.h"
@@ -4341,6 +4342,8 @@ build_int_cstu (tree type, unsigned HOST_WIDE_INT cst)
 extern tree build_int_cst (tree, HOST_WIDE_INT);
 extern tree build_int_cst_type (tree, HOST_WIDE_INT);
 extern tree build_int_cst_wide (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT);
+extern tree make_vector_stat (unsigned MEM_STAT_DECL);
+#define make_vector(n) make_vector_stat (n MEM_STAT_INFO)
 extern tree build_vector_stat (tree, tree * MEM_STAT_DECL);
 #define build_vector(t,v) build_vector_stat (t, v MEM_STAT_INFO)
 extern tree build_vector_from_ctor (tree, VEC(constructor_elt,gc) *);