diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-11-13 09:03:07 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-11-13 09:03:07 +0000 |
commit | e4020b28d02a00d478a3a769855ae6a8d9cc6b26 (patch) | |
tree | 8795d85f2e900a5d8c52ef2b19865109b138051a /gcc | |
parent | 3f446c27195400aea98ff9c37ed2651ab54f7c03 (diff) | |
download | gcc-e4020b28d02a00d478a3a769855ae6a8d9cc6b26.zip gcc-e4020b28d02a00d478a3a769855ae6a8d9cc6b26.tar.gz gcc-e4020b28d02a00d478a3a769855ae6a8d9cc6b26.tar.bz2 |
Don't assign a cost to vectorizable_assignment
vectorizable_assignment handles true SSA-to-SSA copies (which hopefully
we don't see in practice) and no-op conversions that are required
to maintain correct gimple, such as changes between signed and
unsigned types. These cases shouldn't generate any code and so
shouldn't count against either the scalar or vector costs.
Later patches test this, but it seemed worth splitting out.
2019-11-13 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vectorizer.h (vect_nop_conversion_p): Declare.
* tree-vect-stmts.c (vect_nop_conversion_p): New function.
(vectorizable_assignment): Don't add a cost for nop conversions.
* tree-vect-loop.c (vect_compute_single_scalar_iteration_cost):
Likewise.
* tree-vect-slp.c (vect_bb_slp_scalar_cost): Likewise.
From-SVN: r278122
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 4 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 2 | ||||
-rw-r--r-- | gcc/tree-vect-stmts.c | 27 | ||||
-rw-r--r-- | gcc/tree-vectorizer.h | 1 |
5 files changed, 41 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb34395..9054178 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2019-11-13 Richard Sandiford <richard.sandiford@arm.com> + * tree-vectorizer.h (vect_nop_conversion_p): Declare. + * tree-vect-stmts.c (vect_nop_conversion_p): New function. + (vectorizable_assignment): Don't add a cost for nop conversions. + * tree-vect-loop.c (vect_compute_single_scalar_iteration_cost): + Likewise. + * tree-vect-slp.c (vect_bb_slp_scalar_cost): Likewise. + +2019-11-13 Richard Sandiford <richard.sandiford@arm.com> + * tree-vect-stmts.c (vect_model_promotion_demotion_cost): Take the number of ncopies as an additional argument. (vectorizable_conversion): Update call accordingly. Use "modifier" diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index d9f4134..75ec9e6 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1125,7 +1125,9 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo) else kind = scalar_store; } - else + else if (vect_nop_conversion_p (stmt_info)) + continue; + else kind = scalar_stmt; record_stmt_cost (&LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo), diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 4bc0cc7..a2c70ec 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2893,6 +2893,8 @@ vect_bb_slp_scalar_cost (basic_block bb, else kind = scalar_store; } + else if (vect_nop_conversion_p (stmt_info)) + continue; else kind = scalar_stmt; record_stmt_cost (cost_vec, 1, kind, stmt_info, 0, vect_body); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 53f4189..c8a43ad 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -5281,6 +5281,29 @@ vectorizable_conversion (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, return true; } +/* Return true if we can assume from the scalar form of STMT_INFO that + neither the scalar nor the vector forms will generate code. STMT_INFO + is known not to involve a data reference. */ + +bool +vect_nop_conversion_p (stmt_vec_info stmt_info) +{ + gassign *stmt = dyn_cast <gassign *> (stmt_info->stmt); + if (!stmt) + return false; + + tree lhs = gimple_assign_lhs (stmt); + tree_code code = gimple_assign_rhs_code (stmt); + tree rhs = gimple_assign_rhs1 (stmt); + + if (code == SSA_NAME || code == VIEW_CONVERT_EXPR) + return true; + + if (CONVERT_EXPR_CODE_P (code)) + return tree_nop_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs)); + + return false; +} /* Function vectorizable_assignment. @@ -5396,7 +5419,9 @@ vectorizable_assignment (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, { STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type; DUMP_VECT_SCOPE ("vectorizable_assignment"); - vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, cost_vec); + if (!vect_nop_conversion_p (stmt_info)) + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, + cost_vec); return true; } diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index e556e0e..e93ccc7 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1650,6 +1650,7 @@ extern tree vect_get_vec_def_for_stmt_copy (vec_info *, tree); extern bool vect_transform_stmt (stmt_vec_info, gimple_stmt_iterator *, slp_tree, slp_instance); extern void vect_remove_stores (stmt_vec_info); +extern bool vect_nop_conversion_p (stmt_vec_info); extern opt_result vect_analyze_stmt (stmt_vec_info, bool *, slp_tree, slp_instance, stmt_vector_for_cost *); extern void vect_get_load_cost (stmt_vec_info, int, bool, |