Even instance roots can be mentioned in externs of other instances
and thus have to be kept scalar. Consider that.
PR tree-optimization/125080
* tree-vect-slp.cc (vect_bb_slp_mark_stmts_vectorized): Only
add instance root stmts to scalar coverage if they do not
appear in externs.
* gcc.dg/torture/pr125080.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+
+struct S { double a, b, c, d, e, f; };
+void g(struct S *s, double *p, double *q, long n)
+{
+ for (long i; i < n; ++i) {
+ s->b = s->c * p[i];
+ s->a = s->f * s->d + s->b;
+ q[i] += s->f;
+ if (s->e) s->a = s->e;
+ }
+}
for (auto instance : BB_VINFO_SLP_INSTANCES (vinfo))
{
for (auto stmt : SLP_INSTANCE_ROOT_STMTS (instance))
- STMT_SLP_TYPE (stmt) = pure_slp;
+ if (!scalar_stmts_in_externs.contains (stmt))
+ STMT_SLP_TYPE (stmt) = pure_slp;
auto_vec<stmt_vec_info> worklist;
for (auto stmt : SLP_TREE_SCALAR_STMTS (SLP_INSTANCE_TREE (instance)))
{