https://gcc.gnu.org/g:19fae3c44356017e3f36626d9d57fe0081533fad

commit r17-3919-g19fae3c44356017e3f36626d9d57fe0081533fad
Author: Richard Biener <[email protected]>
Date:   Fri Sep 4 09:15:14 2026 +0200

    tree-optimization/127206 - use cached SLP schedule failure state properly
    
    The following makes sure to properly use cached failure state for
    a previously covered entry.
    
            PR tree-optimization/127206
            * tree-vect-slp.cc (vect_schedule_slp): If scc_info is already
            present, use its failure state.
    
            * gcc.dg/vect/bb-slp-pr127206.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr127206.c | 20 ++++++++++++++++++++
 gcc/tree-vect-slp.cc                        | 14 +++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr127206.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr127206.c
new file mode 100644
index 000000000000..1afb19e1d2e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr127206.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+int a, l, b, c, h, i, m;
+long e, g;
+short f[4], n;
+short f_1;
+bool j;
+void k(int, ...);
+void o() {
+  int p = f[0] + f[3 * e] + f_1 + f_1;
+  for (; m;)
+    if (p) __builtin_trap();
+  c = *f - 2 + n;
+  b = f[3 * e] - 2 + n;
+  int q = l + c;
+  int r = a + b;
+  int dq = c + b;
+  int d = q + r;
+  if (d) k(d, e, q, dq, r);
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 4f4fa4c330b3..9a2bf07514c8 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -12813,11 +12813,15 @@ vect_schedule_slp (vec_info *vinfo, vec<slp_instance> 
&slp_instances,
        }
       /* Schedule the tree of INSTANCE, scheduling SCCs in a way to
         have a PHI be the node breaking the cycle.  */
-      bool res = true;
-      auto_vec<slp_tree> stack;
-      if (!scc_info.get (node))
-       res &= vect_schedule_scc (vinfo, node, instance, scc_info,
-                                 maxdfs, stack, place_only);
+      bool res;
+      if (slp_scc_info *info = scc_info.get (node))
+       res = info->res;
+      else
+       {
+         auto_vec<slp_tree> stack;
+         res = vect_schedule_scc (vinfo, node, instance, scc_info,
+                                  maxdfs, stack, place_only);
+       }
 
       if (!SLP_INSTANCE_ROOT_STMTS (instance).is_empty ())
        {

Reply via email to