mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-15 14:01:04 +08:00
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
This commit is contained in:
parent
3f446c2719
commit
e4020b28d0
@ -1,3 +1,12 @@
|
||||
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
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user