Under some circumstances we can end up picking a not relevant stmt
as representative of a SLP node.  Instead of skipping stmt analysis
and declaring success we have to either ignore relevancy throughout
the code base or fail SLP operation verification.  The following
does the latter.

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

        PR tree-optimization/116819
        * tree-vect-stmts.cc (vect_analyze_stmt): When the SLP
        representative isn't relevant signal failure instead of
        success.
---
 gcc/tree-vect-stmts.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index f7867c0803b..7e0a8095fe8 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -13289,6 +13289,12 @@ vect_analyze_stmt (vec_info *vinfo,
           if (dump_enabled_p ())
             dump_printf_loc (MSG_NOTE, vect_location, "irrelevant.\n");
 
+         if (node)
+           return opt_result::failure_at (stmt_info->stmt,
+                                          "not vectorized:"
+                                          " irrelevant stmt as SLP node %p "
+                                          "representative.\n",
+                                          (void *)node);
           return opt_result::success ();
         }
     }
-- 
2.43.0

Reply via email to