diff mbox

Fix PR51482

Message ID alpine.LNX.2.00.1112091218140.4527@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 9, 2011, 11:18 a.m. UTC
This makes sure to not have ENUM/BOOL component type vectors.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2011-12-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/51482
	* tree-vect-stmts.c (get_vectype_for_scalar_type_and_size):
	Make sure to only create REAL_TYPE and INTEGER_TYPE component
	vectors.

	* g++.dg/torture/pr51482.C: New testcase.
diff mbox

Patch

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 182154)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -5705,6 +5705,10 @@  get_vectype_for_scalar_type_and_size (tr
   if (nbytes == 0)
     return NULL_TREE;
 
+  if (GET_MODE_CLASS (inner_mode) != MODE_INT
+      && GET_MODE_CLASS (inner_mode) != MODE_FLOAT)
+    return NULL_TREE;
+
   /* We can't build a vector type of elements with alignment bigger than
      their size.  */
   if (nbytes < TYPE_ALIGN_UNIT (scalar_type))
@@ -5713,16 +5717,15 @@  get_vectype_for_scalar_type_and_size (tr
   /* For vector types of elements whose mode precision doesn't
      match their types precision we use a element type of mode
      precision.  The vectorization routines will have to make sure
-     they support the proper result truncation/extension.  */
+     they support the proper result truncation/extension.
+     We also make sure to build vector types with INTEGER_TYPE
+     component type only.  */
   if (INTEGRAL_TYPE_P (scalar_type)
-      && GET_MODE_BITSIZE (inner_mode) != TYPE_PRECISION (scalar_type))
+      && (GET_MODE_BITSIZE (inner_mode) != TYPE_PRECISION (scalar_type)
+	  || TREE_CODE (scalar_type) != INTEGER_TYPE))
     scalar_type = build_nonstandard_integer_type (GET_MODE_BITSIZE (inner_mode),
 						  TYPE_UNSIGNED (scalar_type));
 
-  if (GET_MODE_CLASS (inner_mode) != MODE_INT
-      && GET_MODE_CLASS (inner_mode) != MODE_FLOAT)
-    return NULL_TREE;
-
   /* We shouldn't end up building VECTOR_TYPEs of non-scalar components.
      When the component mode passes the above test simply use a type
      corresponding to that mode.  The theory is that any use that
Index: gcc/testsuite/g++.dg/torture/pr51482.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr51482.C	(revision 0)
+++ gcc/testsuite/g++.dg/torture/pr51482.C	(revision 0)
@@ -0,0 +1,30 @@ 
+// { dg-do compile }
+
+typedef enum { CLASS_IN = 1, CLASS_OUT = -1 } FERGUSON_KEY_CLASS, BEZIER_KEY_CLASS;
+typedef class flag_interface { } VECT3DF_SIMPLE;
+typedef struct vect3df {
+    float x,y,z;
+} VECT3DF, VECT;
+typedef struct vect4df : public vect3df {
+    float w;
+} VECT4DF, WVECT;
+typedef class llist_item { } ANIM_KEY;
+typedef class anim_track : public flag_interface, public llist_item { } ANIM_KEY_BEZ;
+typedef class anim_track_bezier : public anim_track { } ANIM_KEY_BEZ_WVECT;
+typedef class anim_track_bez_wvect : public anim_track_bezier {
+    WVECT * tangent(int kn, BEZIER_KEY_CLASS key_class, WVECT *p_tn);
+} ANIM_TRACK_BEZ_WVECT;
+WVECT * anim_track_bez_wvect::tangent(int kn, BEZIER_KEY_CLASS key_class, WVECT *p_tn)
+{
+  float bias,continuity,tension,tn1,bp1;
+  WVECT *p_p0,*p_p1,*p_p2,         t1,         g1,g2,g3;
+  g1.x = (p_p1->x - p_p0->x)*bp1;
+  g1.y = (p_p1->y - p_p0->y)*bp1;
+  g1.z = (p_p1->z - p_p0->z)*bp1;
+  g1.w = (p_p1->w - p_p0->w)*bp1;
+  bp1 = (0.5f + key_class*0.5f*continuity);
+  p_tn->x = (g1.x + g3.x*bp1)*tn1;
+  p_tn->y = (g1.y + g3.y*bp1)*tn1;
+  p_tn->z = (g1.z + g3.z*bp1)*tn1;
+  p_tn->w = (g1.w + g3.w*bp1)*tn1;
+}