re PR tree-optimization/71264 (ICE in convert_move)
authorRichard Biener <rguenther@suse.de>
Wed, 25 May 2016 10:57:53 +0000 (10:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 25 May 2016 10:57:53 +0000 (10:57 +0000)
2016-05-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71264
* tree-vect-stmts.c (vect_init_vector): Properly deal with
vector type val.

* gcc.dg/vect/pr71264.c: New testcase.

From-SVN: r236699

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr71264.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index cad9dab8cbc6032fd9cd93380a122a20e20de9db..121804eca709236adf3a8dae43abb1941da33f78 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71264
+       * tree-vect-stmts.c (vect_init_vector): Properly deal with
+       vector type val.
+
 2016-05-25  Martin Liska  <mliska@suse.cz>
 
        PR tree-optimization/71239
index ad5f0b66a79a9f994d3d88e1410aee124738ea89..897f0f03e50b52006846e4d100bd1f0d773e5e24 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-25  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71264
+       * gcc.dg/vect/pr71264.c: New testcase.
+
 2016-05-25  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/55992
diff --git a/gcc/testsuite/gcc.dg/vect/pr71264.c b/gcc/testsuite/gcc.dg/vect/pr71264.c
new file mode 100644 (file)
index 0000000..4f6381e
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+typedef unsigned char uint8_t;
+typedef uint8_t footype __attribute__((vector_size(4)));
+
+void test(uint8_t *ptr, uint8_t *mask)
+{
+  footype mv;
+  __builtin_memcpy(&mv, mask, sizeof(mv));
+  for (unsigned i = 0; i < 16; i += 4)
+    {
+      footype temp;
+      __builtin_memcpy(&temp, &ptr[i], sizeof(temp));
+      temp ^= mv;
+      __builtin_memcpy(&ptr[i], &temp, sizeof(temp));
+    }
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
index f11f22e3eb8667533cc85f7b41839fdee2d3e942..d2e16d0b9296aa422b2158f037d4dfdd25e5000b 100644 (file)
@@ -1256,10 +1256,11 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
   gimple *init_stmt;
   tree new_temp;
 
-  if (TREE_CODE (type) == VECTOR_TYPE
-      && TREE_CODE (TREE_TYPE (val)) != VECTOR_TYPE)
+  /* We abuse this function to push sth to a SSA name with initial 'val'.  */
+  if (! useless_type_conversion_p (type, TREE_TYPE (val)))
     {
-      if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
+      gcc_assert (TREE_CODE (type) == VECTOR_TYPE);
+      if (! types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
        {
          /* Scalar boolean value should be transformed into
             all zeros or all ones value before building a vector.  */
@@ -1284,7 +1285,13 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
          else
            {
              new_temp = make_ssa_name (TREE_TYPE (type));
-             init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val);
+             if (! INTEGRAL_TYPE_P (TREE_TYPE (val)))
+               init_stmt = gimple_build_assign (new_temp,
+                                                fold_build1 (VIEW_CONVERT_EXPR,
+                                                             TREE_TYPE (type),
+                                                             val));
+             else
+               init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val);
              vect_init_vector_1 (stmt, init_stmt, gsi);
              val = new_temp;
            }