re PR tree-optimization/66165 (vect_transform_slp_perm_load: vec out of range ?)
authorRichard Biener <rguenther@suse.de>
Tue, 19 May 2015 09:36:35 +0000 (09:36 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 19 May 2015 09:36:35 +0000 (09:36 +0000)
2015-05-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66165
* tree-vect-slp.c (vect_supported_load_permutation_p): Add guard
for no load permutation.

* gcc.dg/torture/pr66165.c: New testcase.

PR tree-optimization/66185
* tree-vect-slp.c (vect_build_slp_tree): Properly roll back
when building the SLP node from scalars.

* gcc.dg/torture/pr66185.c: New testcase.

From-SVN: r223349

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr66165.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr66185.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 46a45d4c15b3fe0b946161fc72971478027743d5..ed64b470784a9e1ce68eb2492afc02dc4041cfa4 100644 (file)
@@ -1,3 +1,13 @@
+2015-05-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66165
+       * tree-vect-slp.c (vect_supported_load_permutation_p): Add guard
+       for no load permutation.
+
+       PR tree-optimization/66185
+       * tree-vect-slp.c (vect_build_slp_tree): Properly roll back
+       when building the SLP node from scalars.
+
 2015-05-19  Eric Botcazou  <ebotcazou@adacore.com>
            Tristan Gingold  <gingold@adacore.com>
 
index 28533716d91421055bb9b7d28c739b0d683f7081..cffec1b62db9260d3b5ee781715bf31f308d0c3c 100644 (file)
@@ -1,3 +1,11 @@
+2015-05-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66165
+       * gcc.dg/torture/pr66165.c: New testcase.
+
+       PR tree-optimization/66185
+       * gcc.dg/torture/pr66185.c: New testcase.
+
 2015-05-19  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/54236
diff --git a/gcc/testsuite/gcc.dg/torture/pr66165.c b/gcc/testsuite/gcc.dg/torture/pr66165.c
new file mode 100644 (file)
index 0000000..07407d0
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+void foo(double *d, double *a)
+{
+  d[0] += d[2];
+  d[1] += d[3];
+  d[2] += d[4];
+  d[3] += d[5];
+  a[0] = d[0];
+  a[1] = d[1];
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr66185.c b/gcc/testsuite/gcc.dg/torture/pr66185.c
new file mode 100644 (file)
index 0000000..5a57ac1
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+unsigned int a;
+int b[5], c;
+
+int
+main ()
+{
+  for (c = 0; c < 4; c++)
+    b[c] = b[c+1] > ((b[0] > 0) > a);
+
+  return 0;
+}
index b78f7d82d3525e010ec18c2b5c2be17eb13add03..cad1604b438909413e4724a385014fc15deddf29 100644 (file)
@@ -1103,6 +1103,16 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
             scalar version.  */
          && !is_pattern_stmt_p (vinfo_for_stmt (stmt)))
        {
+         unsigned int j;
+         slp_tree grandchild;
+
+         /* Roll back.  */
+         *max_nunits = old_max_nunits;
+         loads->truncate (old_nloads);
+         FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (child), j, grandchild)
+           vect_free_slp_tree (grandchild);
+         SLP_TREE_CHILDREN (child).truncate (0);
+
          dump_printf_loc (MSG_NOTE, vect_location,
                           "Building vector operands from scalars\n");
          oprnd_info->def_stmts = vNULL;
@@ -1400,6 +1410,8 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
          no permutation is necessary.  */
       FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (slp_instn), i, node)
         {
+         if (!SLP_TREE_LOAD_PERMUTATION (node).exists ())
+           continue;
          bool subchain_p = true;
           next_load = NULL;
           FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), j, load)