Patchwork Fix PR50609

login
register
mail settings
Submitter Richard Guenther
Date Oct. 4, 2011, 3:21 p.m.
Message ID <alpine.LNX.2.00.1110041720360.2130@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/117653/
State New
Headers show

Comments

Richard Guenther - Oct. 4, 2011, 3:21 p.m.
This fixes PR50609, we need to do something sensible for VECTOR_TYPE
constructors, which is not dispatch to fold_nonarray_ctor_reference.
Instead fold_array_ctor_reference can be conveniently re-used.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2011-10-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/50609
	* gimple-fold.c (fold_array_ctor_reference): Also handle
	vector typed constructors.
	(fold_ctor_reference): Dispatch to fold_array_ctor_reference
	for vector typed constructors.

Patch

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 179505)
+++ gcc/gimple-fold.c	(working copy)
@@ -2747,10 +2747,12 @@  fold_array_ctor_reference (tree type, tr
   double_int low_bound, elt_size;
   double_int index, max_index;
   double_int access_index;
-  tree domain_type = TYPE_DOMAIN (TREE_TYPE (ctor));
+  tree domain_type = NULL_TREE;
   HOST_WIDE_INT inner_offset;
 
   /* Compute low bound and elt size.  */
+  if (TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE)
+    domain_type = TYPE_DOMAIN (TREE_TYPE (ctor));
   if (domain_type && TYPE_MIN_VALUE (domain_type))
     {
       /* Static constructors for variably sized objects makes no sense.  */
@@ -2917,7 +2919,8 @@  fold_ctor_reference (tree type, tree cto
   if (TREE_CODE (ctor) == CONSTRUCTOR)
     {
 
-      if (TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE)
+      if (TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE
+	  || TREE_CODE (TREE_TYPE (ctor)) == VECTOR_TYPE)
 	return fold_array_ctor_reference (type, ctor, offset, size);
       else
 	return fold_nonarray_ctor_reference (type, ctor, offset, size);