The previous change missed to check for patterns again, the following
corrects that.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

2020-10-28  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/97615
        * tree-vect-slp.c (vect_build_slp_tree_2): Do not build
        an external from pattern defs.

        * gcc.dg/vect/bb-slp-pr97615.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr97615.c | 23 ++++++++++++++++++++++
 gcc/tree-vect-slp.c                        |  3 ++-
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr97615.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr97615.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97615.c
new file mode 100644
index 00000000000..b4a8aa2f4a3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97615.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+short *a;
+int e, f;
+
+void
+foo (int c, int d)
+{
+  short *a1, *a2, *a3;
+  a1 = a++;
+  *a1 = c;
+  a2 = a++;
+  *a2 = *a1;
+  a3 = a++;
+  *a3 = d;
+}
+
+void
+bar (void)
+{
+  foo (e + f - 2, e + f - 1);
+  foo (e + f - 1, 0);
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 5eafc037955..9f1da3070f5 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1599,7 +1599,8 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
        }
 
       if (is_a <bb_vec_info> (vinfo)
-         && oprnd_info->first_dt == vect_internal_def)
+         && oprnd_info->first_dt == vect_internal_def
+         && !oprnd_info->any_pattern)
        {
          /* For BB vectorization, if all defs are the same do not
             bother to continue the build along the single-lane
-- 
2.26.2

Reply via email to