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 000000000000..b4a8aa2f4a31 --- /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 5eafc037955f..9f1da3070f5c 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 (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