/* Implement TARGET_VECTORIZE_INIT_COST. */
void *
-aarch64_init_cost (class loop *)
+aarch64_init_cost (class loop *, bool)
{
return new aarch64_vector_costs;
}
/* Implement targetm.vectorize.init_cost. */
static void *
-ix86_init_cost (class loop *)
+ix86_init_cost (class loop *, bool)
{
unsigned *cost = XNEWVEC (unsigned, 3);
cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
/* Implement targetm.vectorize.init_cost. */
static void *
-rs6000_init_cost (struct loop *loop_info)
+rs6000_init_cost (struct loop *loop_info, bool)
{
rs6000_cost_data *data = XNEW (struct _rs6000_cost_data);
data->loop_info = loop_info;
all zeros. GCC can then try to branch around the instruction instead.
@end deftypefn
-@deftypefn {Target Hook} {void *} TARGET_VECTORIZE_INIT_COST (class loop *@var{loop_info})
-This hook should initialize target-specific data structures in preparation for modeling the costs of vectorizing a loop or basic block. The default allocates three unsigned integers for accumulating costs for the prologue, body, and epilogue of the loop or basic block. If @var{loop_info} is non-NULL, it identifies the loop being vectorized; otherwise a single block is being vectorized.
+@deftypefn {Target Hook} {void *} TARGET_VECTORIZE_INIT_COST (class loop *@var{loop_info}, bool @var{costing_for_scalar})
+This hook should initialize target-specific data structures in preparation for modeling the costs of vectorizing a loop or basic block. The default allocates three unsigned integers for accumulating costs for the prologue, body, and epilogue of the loop or basic block. If @var{loop_info} is non-NULL, it identifies the loop being vectorized; otherwise a single block is being vectorized. If @var{costing_for_scalar} is true, it indicates the current cost model is for the scalar version of a loop or block; otherwise it is for the vector version.
@end deftypefn
@deftypefn {Target Hook} unsigned TARGET_VECTORIZE_ADD_STMT_COST (class vec_info *@var{}, void *@var{data}, int @var{count}, enum vect_cost_for_stmt @var{kind}, class _stmt_vec_info *@var{stmt_info}, tree @var{vectype}, int @var{misalign}, enum vect_cost_model_location @var{where})
"allocates three unsigned integers for accumulating costs for the prologue, "
"body, and epilogue of the loop or basic block. If @var{loop_info} is "
"non-NULL, it identifies the loop being vectorized; otherwise a single block "
- "is being vectorized.",
+ "is being vectorized. If @var{costing_for_scalar} is true, it indicates the "
+ "current cost model is for the scalar version of a loop or block; otherwise "
+ "it is for the vector version.",
void *,
- (class loop *loop_info),
+ (class loop *loop_info, bool costing_for_scalar),
default_init_cost)
/* Target function to record N statements of the given kind using the
array of three unsigned ints, set it to zero, and return its address. */
void *
-default_init_cost (class loop *loop_info ATTRIBUTE_UNUSED)
+default_init_cost (class loop *loop_info ATTRIBUTE_UNUSED,
+ bool costing_for_scalar ATTRIBUTE_UNUSED)
{
unsigned *cost = XNEWVEC (unsigned, 3);
cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
poly_uint64);
extern opt_machine_mode default_get_mask_mode (machine_mode);
extern bool default_empty_mask_is_expensive (unsigned);
-extern void *default_init_cost (class loop *);
+extern void *default_init_cost (class loop *, bool);
extern unsigned default_add_stmt_cost (class vec_info *, void *, int,
enum vect_cost_for_stmt,
class _stmt_vec_info *, tree, int,
stmt_vec_info structs for all the stmts in LOOP_IN. */
_loop_vec_info::_loop_vec_info (class loop *loop_in, vec_info_shared *shared)
- : vec_info (vec_info::loop, init_cost (loop_in), shared),
+ : vec_info (vec_info::loop, init_cost (loop_in, false), shared),
loop (loop_in),
bbs (XCNEWVEC (basic_block, loop->num_nodes)),
num_itersm1 (NULL_TREE),
}
/* Now accumulate cost. */
- void *target_cost_data = init_cost (loop);
+ void *target_cost_data = init_cost (loop, true);
stmt_info_for_cost *si;
int j;
FOR_EACH_VEC_ELT (LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo),
/* Reset target cost data. */
destroy_cost_data (LOOP_VINFO_TARGET_COST_DATA (loop_vinfo));
LOOP_VINFO_TARGET_COST_DATA (loop_vinfo)
- = init_cost (LOOP_VINFO_LOOP (loop_vinfo));
+ = init_cost (LOOP_VINFO_LOOP (loop_vinfo), false);
/* Reset accumulated rgroup information. */
release_vec_loop_controls (&LOOP_VINFO_MASKS (loop_vinfo));
release_vec_loop_controls (&LOOP_VINFO_LENS (loop_vinfo));
/* Initialize a bb_vec_info struct for the statements in BBS basic blocks. */
_bb_vec_info::_bb_vec_info (vec<basic_block> _bbs, vec_info_shared *shared)
- : vec_info (vec_info::bb, init_cost (NULL), shared), bbs (_bbs), roots (vNULL)
+ : vec_info (vec_info::bb, init_cost (NULL, false), shared),
+ bbs (_bbs),
+ roots (vNULL)
{
for (unsigned i = 0; i < bbs.length (); ++i)
{
continue;
}
- void *scalar_target_cost_data = init_cost (NULL);
+ void *scalar_target_cost_data = init_cost (NULL, true);
do
{
add_stmt_cost (bb_vinfo, scalar_target_cost_data,
destroy_cost_data (scalar_target_cost_data);
/* Complete the target-specific vector cost calculation. */
- void *vect_target_cost_data = init_cost (NULL);
+ void *vect_target_cost_data = init_cost (NULL, false);
do
{
add_stmt_cost (bb_vinfo, vect_target_cost_data,
/* Alias targetm.vectorize.init_cost. */
static inline void *
-init_cost (class loop *loop_info)
+init_cost (class loop *loop_info, bool costing_for_scalar)
{
- return targetm.vectorize.init_cost (loop_info);
+ return targetm.vectorize.init_cost (loop_info, costing_for_scalar);
}
extern void dump_stmt_cost (FILE *, void *, int, enum vect_cost_for_stmt,