2016-01-18 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Jan 2016 09:14:14 +0000 (09:14 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Jan 2016 09:14:14 +0000 (09:14 +0000)
PR tree-optimization/69170
* tree-vect-slp.c (vect_build_slp_tree): Verify we are not
building a vector from scalar results of a pattern stmt.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232496 138bc75d-0d04-0410-961f-82ee72b054a4

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

index c869492..1cc9288 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69170
+       * tree-vect-slp.c (vect_build_slp_tree): Verify we are not
+       building a vector from scalar results of a pattern stmt.
+
 2016-01-18  Jakub Jelinek  <jakub@redhat.com>
 
        * haifa-sched.c (autopref_multipass_init): Work around
index bd9a116..9016093 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69170
+       * gcc.dg/torture/pr69170.c: New testcase.
+
 2016-01-17 John David Anglin  <danglin@gcc.gnu.org>
 
        * gcc.dg/torture/builtin-integral-1.c: Require c99_runtime.
diff --git a/gcc/testsuite/gcc.dg/torture/pr69170.c b/gcc/testsuite/gcc.dg/torture/pr69170.c
new file mode 100644 (file)
index 0000000..2af0bde
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+typedef long sha2_word_t;
+typedef struct {
+    sha2_word_t length_upper, length_lower;
+    char buf[];
+} hash_state;
+int a;
+hash_state b;
+void fn1()
+{
+  a = 0;
+  for (; a < 8; a++)
+    b.buf[a + 1024 / 8] = b.length_upper >> (1 - a) * 5;
+  a = 0;
+  for (; a < 8; a++)
+    b.buf[a + 1024 / 8 + 8] = b.length_lower >> (1 - a) * 5;
+}
index 5767e19..d5bd92e 100644 (file)
@@ -966,7 +966,12 @@ vect_build_slp_tree (vec_info *vinfo,
        {
          /* If we have all children of child built up from scalars then just
             throw that away and build it up this node from scalars.  */
-         if (!SLP_TREE_CHILDREN (child).is_empty ())
+         if (!SLP_TREE_CHILDREN (child).is_empty ()
+             /* ???  Rejecting patterns this way doesn't work.  We'd have to
+                do extra work to cancel the pattern so the uses see the
+                scalar version.  */
+             && !is_pattern_stmt_p
+                   (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[0])))
            {
              slp_tree grandchild;
 
@@ -1110,7 +1115,12 @@ vect_build_slp_tree (vec_info *vinfo,
 
              /* If we have all children of child built up from scalars then
                 just throw that away and build it up this node from scalars.  */
-             if (!SLP_TREE_CHILDREN (child).is_empty ())
+             if (!SLP_TREE_CHILDREN (child).is_empty ()
+                 /* ???  Rejecting patterns this way doesn't work.  We'd have
+                    to do extra work to cancel the pattern so the uses see the
+                    scalar version.  */
+                 && !is_pattern_stmt_p
+                       (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (child)[0])))
                {
                  unsigned int j;
                  slp_tree grandchild;