From f049868d8db773da4be61d82025e97453d6e9f2b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 15 Aug 2023 13:05:32 +0200 Subject: Support constants and externals in BB reduction vectorization The following supports vectorizing BB reductions involving a constant or an invariant. * tree-vectorizer.h (_slp_instance::remain_stmts): Change to ... (_slp_instance::remain_defs): ... this. (SLP_INSTANCE_REMAIN_STMTS): Rename to ... (SLP_INSTANCE_REMAIN_DEFS): ... this. (slp_root::remain): New. (slp_root::slp_root): Adjust. * tree-vect-slp.cc (vect_free_slp_instance): Adjust. (vect_build_slp_instance): Get extra remain parameter, adjust former handling of a cut off stmt. (vect_analyze_slp_instance): Adjust. (vect_analyze_slp): Likewise. (_bb_vec_info::~_bb_vec_info): Likewise. (vectorizable_bb_reduc_epilogue): Dump something if we fail. (vect_slp_check_for_constructors): Handle non-internal defs as remain defs of a reduction. (vectorize_slp_instance_root_stmt): Adjust. * gcc.dg/vect/bb-slp-75.c: New testcase. --- gcc/tree-vectorizer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 5987a32..1de1449 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -259,7 +259,7 @@ public: /* For slp_inst_kind_bb_reduc the defs that were not vectorized, NULL otherwise. */ - vec remain_stmts; + vec remain_defs; /* The unrolling factor required to vectorized this SLP instance. */ poly_uint64 unrolling_factor; @@ -289,7 +289,7 @@ public: #define SLP_INSTANCE_UNROLLING_FACTOR(S) (S)->unrolling_factor #define SLP_INSTANCE_LOADS(S) (S)->loads #define SLP_INSTANCE_ROOT_STMTS(S) (S)->root_stmts -#define SLP_INSTANCE_REMAIN_STMTS(S) (S)->remain_stmts +#define SLP_INSTANCE_REMAIN_DEFS(S) (S)->remain_defs #define SLP_INSTANCE_KIND(S) (S)->kind #define SLP_TREE_CHILDREN(S) (S)->children @@ -1027,11 +1027,12 @@ loop_vec_info_for_loop (class loop *loop) struct slp_root { slp_root (slp_instance_kind kind_, vec stmts_, - vec roots_) - : kind(kind_), stmts(stmts_), roots(roots_) {} + vec roots_, vec remain_ = vNULL) + : kind(kind_), stmts(stmts_), roots(roots_), remain(remain_) {} slp_instance_kind kind; vec stmts; vec roots; + vec remain; }; typedef class _bb_vec_info : public vec_info -- cgit v1.1