This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix SLP ICE (PR tree-optimization/69083)


Hi!

The vec-cmp SLP patch added
+                 if (VECTOR_BOOLEAN_TYPE_P (vector_type))
+                   {
+                     /* Can't use VIEW_CONVERT_EXPR for booleans because
+                        of possibly different sizes of scalar value and
+                        vector element.  */
...
+                   }
hunk a few lines above this spot, but that only handles constants.
For non-constants, the problem is similar, boolean vector element type might
have different size from the op's type, but it really should be fold
convertible to that, so while we can't use VCE, we can use a NOP_EXPR
instead.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-01-04  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/69083
	* tree-vect-slp.c (vect_get_constant_vectors): For
	VECTOR_BOOLEAN_TYPE_P assert op is fold_convertible_p to vector_type's
	element type.  If op is fold_convertible_p to vector_type's element
	type, use NOP_EXPR instead of VCE.

	* gcc.dg/vect/pr69083.c: New test.

--- gcc/tree-vect-slp.c.jj	2015-12-18 09:38:27.000000000 +0100
+++ gcc/tree-vect-slp.c	2016-01-04 12:56:20.800412147 +0100
@@ -2967,9 +2967,22 @@ vect_get_constant_vectors (tree op, slp_
 		{
 		  tree new_temp = make_ssa_name (TREE_TYPE (vector_type));
 		  gimple *init_stmt;
-		  op = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vector_type), op);
-		  init_stmt
-		    = gimple_build_assign (new_temp, VIEW_CONVERT_EXPR, op);
+		  if (VECTOR_BOOLEAN_TYPE_P (vector_type))
+		    {
+		      gcc_assert (fold_convertible_p (TREE_TYPE (vector_type),
+						      op));
+		      init_stmt = gimple_build_assign (new_temp, NOP_EXPR, op);
+		    }
+		  else if (fold_convertible_p (TREE_TYPE (vector_type), op))
+		    init_stmt = gimple_build_assign (new_temp, NOP_EXPR, op);
+		  else
+		    {
+		      op = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vector_type),
+				   op);
+		      init_stmt
+			= gimple_build_assign (new_temp, VIEW_CONVERT_EXPR,
+					       op);
+		    }
 		  gimple_seq_add_stmt (&ctor_seq, init_stmt);
 		  op = new_temp;
 		}
--- gcc/testsuite/gcc.dg/vect/pr69083.c.jj	2016-01-04 13:11:51.958279240 +0100
+++ gcc/testsuite/gcc.dg/vect/pr69083.c	2016-01-04 13:12:36.142663787 +0100
@@ -0,0 +1,20 @@
+/* PR tree-optimization/69083 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+int d;
+short f;
+
+void
+foo (int a, int b, int e, short c)
+{
+  for (; e; e++)
+    {
+      int j;
+      for (j = 0; j < 3; j++)
+	{
+	  f = 7 >> b ? a : b;
+	  d |= c == 1 ^ 1 == f;
+	}
+    }
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]