From d4f3c3efc669afe6e270344ff73c7471fea67ce7 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 3 Dec 2024 08:52:48 +0100 Subject: Use the number of relevant stmts to limit SLP build The following removes scalar stmt counting from loop vectorization and using that as base to limit both the SLP tree final size and discovery. Instead use the number of relevant stmts for that which is conveniently the number of stmt_vec_infos we create which in turn includes things like pattern stmts. PR tree-optimization/117874 * tree-vectorizer.h (vec_info_shared::n_stmts): Remove. (LOOP_VINFO_N_STMTS): Likewise. * tree-vectorizer.cc (vec_info_shared::vec_info_shared): Adjust. * tree-vect-loop.cc (vect_get_datarefs_in_loop): Do not count stmts. (vect_analyze_loop_2): Adjust. Pass stmt_vec_info.length () to vect_analyze_slp as SLP tree size limit. --- gcc/tree-vect-loop.cc | 10 +++------- gcc/tree-vectorizer.cc | 3 +-- gcc/tree-vectorizer.h | 4 ---- 3 files changed, 4 insertions(+), 13 deletions(-) (limited to 'gcc') diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 8520960..4f401cd 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -2499,10 +2499,8 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo, static opt_result vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs, - vec *datarefs, - unsigned int *n_stmts) + vec *datarefs) { - *n_stmts = 0; for (unsigned i = 0; i < loop->num_nodes; i++) for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) @@ -2510,7 +2508,6 @@ vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs, gimple *stmt = gsi_stmt (gsi); if (is_gimple_debug (stmt)) continue; - ++(*n_stmts); opt_result res = vect_find_stmt_data_reference (loop, stmt, datarefs, NULL, 0); if (!res) @@ -2786,8 +2783,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, { opt_result res = vect_get_datarefs_in_loop (loop, LOOP_VINFO_BBS (loop_vinfo), - &LOOP_VINFO_DATAREFS (loop_vinfo), - &LOOP_VINFO_N_STMTS (loop_vinfo)); + &LOOP_VINFO_DATAREFS (loop_vinfo)); if (!res) { if (dump_enabled_p ()) @@ -2898,7 +2894,7 @@ start_over: { /* Check the SLP opportunities in the loop, analyze and build SLP trees. */ - ok = vect_analyze_slp (loop_vinfo, LOOP_VINFO_N_STMTS (loop_vinfo), + ok = vect_analyze_slp (loop_vinfo, loop_vinfo->stmt_vec_infos.length (), slp == 1); if (!ok) return ok; diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc index 9a068a4..0bec280 100644 --- a/gcc/tree-vectorizer.cc +++ b/gcc/tree-vectorizer.cc @@ -480,8 +480,7 @@ vec_info::~vec_info () } vec_info_shared::vec_info_shared () - : n_stmts (0), - datarefs (vNULL), + : datarefs (vNULL), datarefs_copy (vNULL), ddrs (vNULL) { diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 7f69a3f..1059fc5 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -474,9 +474,6 @@ public: void save_datarefs(); void check_datarefs(); - /* The number of scalar stmts. */ - unsigned n_stmts; - /* All data references. Freed by free_data_refs, so not an auto_vec. */ vec datarefs; vec datarefs_copy; @@ -1070,7 +1067,6 @@ public: #define LOOP_VINFO_RGROUP_IV_TYPE(L) (L)->rgroup_iv_type #define LOOP_VINFO_PARTIAL_VECTORS_STYLE(L) (L)->partial_vector_style #define LOOP_VINFO_PTR_MASK(L) (L)->ptr_mask -#define LOOP_VINFO_N_STMTS(L) (L)->shared->n_stmts #define LOOP_VINFO_LOOP_NEST(L) (L)->shared->loop_nest #define LOOP_VINFO_DATAREFS(L) (L)->shared->datarefs #define LOOP_VINFO_DDRS(L) (L)->shared->ddrs -- cgit v1.1