This corrects assessing whether a stmt is inside the vector region,
checking random stmt UIDs against -1 does not work for loop vectorization.

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

        * tree-vect-slp.cc (vect_schedule_slp_node): Correct in-region
        stmt check.
---
 gcc/tree-vect-slp.cc | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index fe406a4cb6a..7cb0c749fa3 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -11953,15 +11953,12 @@ vect_schedule_slp_node (vec_info *vinfo,
            unsigned j;
            tree def;
            FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_OPS (child), j, def)
-             if (TREE_CODE (def) == SSA_NAME
-                 && !SSA_NAME_IS_DEFAULT_DEF (def))
+             /* If the stmt is not inside the region do not
+                use it as possible insertion point.  */
+             if (auto stmt_info = vinfo->lookup_def (def))
                {
-                 gimple *stmt = SSA_NAME_DEF_STMT (def);
-                 if (gimple_uid (stmt) == -1u)
-                   /* If the stmt is not inside the region do not
-                      use it as possible insertion point.  */
-                   ;
-                 else if (!last_stmt)
+                 gimple *stmt = stmt_info->stmt;
+                 if (!last_stmt)
                    last_stmt = stmt;
                  else if (vect_stmt_dominates_stmt_p (last_stmt, stmt))
                    last_stmt = stmt;
-- 
2.51.0

Reply via email to