From fce57248c89d5b990d1f82a2f8eba5a9741c9ad9 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 24 May 2016 14:05:20 +0000 Subject: [PATCH] Clean up PURE_SLP_STMT handling The vectorizable_* routines had many instances of: slp_node || PURE_SLP_STMT (stmt_info) which gives the misleading impression that we can have !slp_node && PURE_SLP_STMT (stmt_info). In this context it's really enough to test slp_node on its own. There are three cases: loop vectorisation only: vectorizable_foo called only with !slp_node pure SLP: vectorizable_foo called only with slp_node hybrid SLP: (e.g. a vector that's used in SLP statements and also in a reduction) - vectorizable_foo called once with slp_node for the SLP uses. - vectorizable_foo called once with !slp_node for the non-SLP uses. Hybrid SLP isn't possible for stores, so I added an explicit assert for that. I also made vectorizable_comparison static, to make it obvious that no other callers outside tree-vect-stmts.c could use it with the !slp && PURE_SLP_STMT combination. Tested on aarch64-linux-gnu and x86_64-linux-gnu. gcc/ * tree-vectorizer.h (vectorizable_comparison): Delete. * tree-vect-loop.c (vectorizable_reduction): Remove redundant PURE_SLP_STMT check. * tree-vect-stmts.c (vectorizable_call): Likewise. (vectorizable_simd_clone_call): Likewise. (vectorizable_conversion): Likewise. (vectorizable_assignment): Likewise. (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. (vectorizable_load): Likewise. (vectorizable_condition): Likewise. (vectorizable_store): Likewise. Assert that we don't have hybrid SLP. (vectorizable_comparison): Make static. Remove redundant PURE_SLP_STMT check. (vect_transform_stmt): Assert that we always have an slp_node if PURE_SLP_STMT. From-SVN: r236642 --- gcc/ChangeLog | 20 ++++++++++++++++++++ gcc/tree-vect-loop.c | 2 +- gcc/tree-vect-stmts.c | 41 +++++++++++++++++++++-------------------- gcc/tree-vectorizer.h | 2 -- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a76178edd00..6eac48e6e8e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2016-05-24 Richard Sandiford + + * tree-vectorizer.h (vectorizable_comparison): Delete. + * tree-vect-loop.c (vectorizable_reduction): Remove redundant + PURE_SLP_STMT check. + * tree-vect-stmts.c (vectorizable_call): Likewise. + (vectorizable_simd_clone_call): Likewise. + (vectorizable_conversion): Likewise. + (vectorizable_assignment): Likewise. + (vectorizable_shift): Likewise. + (vectorizable_operation): Likewise. + (vectorizable_load): Likewise. + (vectorizable_condition): Likewise. + (vectorizable_store): Likewise. Assert that we don't have + hybrid SLP. + (vectorizable_comparison): Make static. Remove redundant + PURE_SLP_STMT check. + (vect_transform_stmt): Assert that we always have an slp_node + if PURE_SLP_STMT. + 2016-05-24 Kyrylo Tkachov * config/arm/neon.md (ashldi3_neon): Replace comparison of INTVAL of diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 153372b4d3d..1471658da76 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -5596,7 +5596,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, if (STMT_VINFO_LIVE_P (vinfo_for_stmt (reduc_def_stmt))) return false; - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = (LOOP_VINFO_VECT_FACTOR (loop_vinfo) diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 1252d335104..d9e9cbbba5c 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2342,7 +2342,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt, } } - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else if (modifier == NARROW && ifn == IFN_LAST) ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_out; @@ -2792,7 +2792,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, return false; /* FORNOW */ - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) return false; /* Process function arguments. */ @@ -3750,7 +3750,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else if (modifier == NARROW) ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_out; @@ -4231,7 +4231,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; @@ -4491,7 +4491,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_in; @@ -4922,7 +4922,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits_in; @@ -5239,6 +5239,10 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, && TREE_CODE (scalar_dest) != MEM_REF) return false; + /* Cannot have hybrid store SLP -- that would mean storing to the + same location twice. */ + gcc_assert (slp == PURE_SLP_STMT (stmt_info)); + gcc_assert (gimple_assign_single_p (stmt)); tree vectype = STMT_VINFO_VECTYPE (stmt_info), rhs_vectype = NULL_TREE; @@ -5250,7 +5254,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp || PURE_SLP_STMT (stmt_info)) + if (slp) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; @@ -5332,9 +5336,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, grouped_store = true; first_stmt = GROUP_FIRST_ELEMENT (stmt_info); group_size = GROUP_SIZE (vinfo_for_stmt (first_stmt)); - if (!slp - && !PURE_SLP_STMT (stmt_info) - && !STMT_VINFO_STRIDED_P (stmt_info)) + if (!slp && !STMT_VINFO_STRIDED_P (stmt_info)) { if (vect_store_lanes_supported (vectype, group_size)) store_lanes_p = true; @@ -5343,7 +5345,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, } if (STMT_VINFO_STRIDED_P (stmt_info) - && (slp || PURE_SLP_STMT (stmt_info)) + && slp && (group_size > nunits || nunits % group_size != 0)) { @@ -6252,7 +6254,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, /* Multiple types in SLP are handled by creating the appropriate number of vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in case of SLP. */ - if (slp || PURE_SLP_STMT (stmt_info)) + if (slp) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; @@ -6305,9 +6307,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, first_stmt = GROUP_FIRST_ELEMENT (stmt_info); group_size = GROUP_SIZE (vinfo_for_stmt (first_stmt)); - if (!slp - && !PURE_SLP_STMT (stmt_info) - && !STMT_VINFO_STRIDED_P (stmt_info)) + if (!slp && !STMT_VINFO_STRIDED_P (stmt_info)) { if (vect_load_lanes_supported (vectype, group_size)) load_lanes_p = true; @@ -6420,8 +6420,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, } else if (STMT_VINFO_STRIDED_P (stmt_info)) { - if ((grouped_load - && (slp || PURE_SLP_STMT (stmt_info))) + if (grouped_load + && slp && (group_size > nunits || nunits % group_size != 0)) { @@ -7499,7 +7499,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi, int nunits = TYPE_VECTOR_SUBPARTS (vectype); tree vectype1 = NULL_TREE, vectype2 = NULL_TREE; - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; @@ -7705,7 +7705,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi, Return FALSE if not a vectorizable STMT, TRUE otherwise. */ -bool +static bool vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, tree reduc_def, slp_tree slp_node) @@ -7739,7 +7739,7 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, mask_type = vectype; nunits = TYPE_VECTOR_SUBPARTS (vectype); - if (slp_node || PURE_SLP_STMT (stmt_info)) + if (slp_node) ncopies = 1; else ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; @@ -8149,6 +8149,7 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi, stmt_vec_info stmt_info = vinfo_for_stmt (stmt); bool done; + gcc_assert (slp_node || !PURE_SLP_STMT (stmt_info)); gimple *old_vec_stmt = STMT_VINFO_VEC_STMT (stmt_info); switch (STMT_VINFO_TYPE (stmt_info)) diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index bd1d55a7fbe..5816006a4db 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1004,8 +1004,6 @@ extern void vect_remove_stores (gimple *); extern bool vect_analyze_stmt (gimple *, bool *, slp_tree); extern bool vectorizable_condition (gimple *, gimple_stmt_iterator *, gimple **, tree, int, slp_tree); -extern bool vectorizable_comparison (gimple *, gimple_stmt_iterator *, - gimple **, tree, int, slp_tree); extern void vect_get_load_cost (struct data_reference *, int, bool, unsigned int *, unsigned int *, stmt_vector_for_cost *, -- 2.30.2