I forgot to guard the promotion to external for the case where the
def is in a pattern.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

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

        PR tree-optimization/97496
        * tree-vect-slp.c (vect_get_and_check_slp_defs): Guard extern
        promotion with not in pattern.

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

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr97496.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97496.c
new file mode 100644
index 00000000000..fa9e9801583
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97496.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+int a;
+int b[1024];
+void c(unsigned g) {
+  if (a) {
+    long e = g, d = e;
+    int f = 0;
+    for (; f < 4; f++) {
+      b[f] = d;
+      d >>= 8;
+    }
+  }
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index f36d8d1c642..0c1447e7aa0 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -582,7 +582,8 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char 
swap,
              continue;
            }
 
-         if (is_a <bb_vec_info> (vinfo))
+         if (is_a <bb_vec_info> (vinfo)
+             && !oprnd_info->any_pattern)
            {
              /* Now for commutative ops we should see whether we can
                 make the other operand matching.  */
-- 
2.26.2

Reply via email to