tree-optimization/97615 - avoid creating externals from patterns
authorRichard Biener <rguenther@suse.de>
Wed, 28 Oct 2020 12:21:53 +0000 (13:21 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 28 Oct 2020 14:04:06 +0000 (15:04 +0100)
The previous change missed to check for patterns again, the following
corrects that.

2020-10-28  Richard Biener  <rguenther@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 [new file with mode: 0644]
gcc/tree-vect-slp.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 (file)
index 0000000..b4a8aa2
--- /dev/null
@@ -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);
+}
index 5eafc037955f322fe1d4015256f963104a1ca68b..9f1da3070f5c06f357f8904d5a05a4bca40029ba 100644 (file)
@@ -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