[PATCH, vectorizer]: Fix PR tree-optimization/32216, ICE: verify_stmts failed (invalid reference prefix)

Uros Bizjak ubizjak@gmail.com
Wed Jun 6 11:53:00 GMT 2007


Hello!

We should always determine signedness of FIX_TRUNC_EXPR and derived
vectorized expressions based on the signedness of output operand.
Signendness of FLOAT_EXPR and derived vectorized expressions should be
determined based on the signedness of input operand.

Attached patch cleans this mess and fixes pr32216. Patch was
bootstrapped on i686-pc-linux-gnu, regression tested for all default
languages. OK for mainline?

2007-06-06  Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/32216
	* tree-vectorizer.c (supportable_widening_operation): Determine
	signedness of FIX_TRUNC_EXPR from output operand.
	(supportable_narrowing_operation): Ditto.
	* tree-vect-generic.c (expand_vector_operations_1): Determine
	signedness of VEC_UNPACK_FLOAT_HI_EXPR and VEC_UNPACK_FLOAT_LO_EXPR
	from input operand.

testsuite/ChangeLog:
	
2007-06-06  Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/32216
	* gcc.dg/vect/pr32216.c: New test.

Uros.
-------------- next part --------------
Index: optabs.c
===================================================================
--- optabs.c	(revision 125355)
+++ optabs.c	(working copy)
@@ -357,6 +357,7 @@ optab_for_tree_code (enum tree_code code
       return TYPE_UNSIGNED (type) ? vec_pack_usat_optab : vec_pack_ssat_optab;
 
     case VEC_PACK_FIX_TRUNC_EXPR:
+      /* The signedness is determined from output operand.  */
       return TYPE_UNSIGNED (type) ?
 	vec_pack_ufix_trunc_optab : vec_pack_sfix_trunc_optab;
 
Index: testsuite/gcc.dg/vect/pr32216.c
===================================================================
--- testsuite/gcc.dg/vect/pr32216.c	(revision 0)
+++ testsuite/gcc.dg/vect/pr32216.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_floatint_cvt } */
+
+unsigned int wlookup2[203];
+
+SetSoundVariables (int x)
+{
+  for (x = 1; x < 32; x++)
+  {
+    wlookup2[x] = (double) 16 / x;
+  }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 125355)
+++ tree-vectorizer.c	(working copy)
@@ -1851,10 +1851,17 @@ supportable_widening_operation (enum tre
       gcc_unreachable ();
     }
 
-  *code1 = c1;
-  *code2 = c2;
-  optab1 = optab_for_tree_code (c1, vectype);
-  optab2 = optab_for_tree_code (c2, vectype);
+  if (code == FIX_TRUNC_EXPR)
+    {
+      /* The signedness is determined from output operand.  */
+      optab1 = optab_for_tree_code (c1, type);
+      optab2 = optab_for_tree_code (c2, type);
+    }
+  else
+    {
+      optab1 = optab_for_tree_code (c1, vectype);
+      optab2 = optab_for_tree_code (c2, vectype);
+    }
 
   if (!optab1 || !optab2)
     return false;
@@ -1867,6 +1874,8 @@ supportable_widening_operation (enum tre
       || insn_data[icode2].operand[0].mode != TYPE_MODE (wide_vectype))
     return false;
 
+  *code1 = c1;
+  *code2 = c2;
   return true;
 }
 
@@ -1918,8 +1927,11 @@ supportable_narrowing_operation (enum tr
       gcc_unreachable ();
     }
 
-  *code1 = c1;
-  optab1 = optab_for_tree_code (c1, vectype);
+  if (code == FIX_TRUNC_EXPR)
+    /* The signedness is determined from output operand.  */
+    optab1 = optab_for_tree_code (c1, type);
+  else
+    optab1 = optab_for_tree_code (c1, vectype);
 
   if (!optab1)
     return false;
@@ -1929,6 +1941,7 @@ supportable_narrowing_operation (enum tr
       || insn_data[icode1].operand[0].mode != TYPE_MODE (narrow_vectype))
     return false;
 
+  *code1 = c1;
   return true;
 }
 
Index: tree-vect-generic.c
===================================================================
--- tree-vect-generic.c	(revision 125355)
+++ tree-vect-generic.c	(working copy)
@@ -412,17 +412,22 @@ expand_vector_operations_1 (block_stmt_i
     return;
   
   gcc_assert (code != CONVERT_EXPR);
+
+  /* The signedness is determined from input argument.  */
+  if (code == VEC_UNPACK_FLOAT_HI_EXPR
+      || code == VEC_UNPACK_FLOAT_LO_EXPR)
+    type = TREE_TYPE (TREE_OPERAND (rhs, 0));
+
   op = optab_for_tree_code (code, type);
 
   /* For widening/narrowing vector operations, the relevant type is of the 
-     arguments, not the widened result.  */
+     arguments, not the widened result.  VEC_UNPACK_FLOAT_*_EXPR is
+     calculated in the same way above.  */
   if (code == WIDEN_SUM_EXPR
       || code == VEC_WIDEN_MULT_HI_EXPR
       || code == VEC_WIDEN_MULT_LO_EXPR
       || code == VEC_UNPACK_HI_EXPR
       || code == VEC_UNPACK_LO_EXPR
-      || code == VEC_UNPACK_FLOAT_HI_EXPR
-      || code == VEC_UNPACK_FLOAT_LO_EXPR
       || code == VEC_PACK_TRUNC_EXPR
       || code == VEC_PACK_SAT_EXPR
       || code == VEC_PACK_FIX_TRUNC_EXPR)


More information about the Gcc-patches mailing list