aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-11-10 12:31:01 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2021-11-10 12:31:01 +0000
commit6ddc6a57a74c3a388eb1626e59005f54c6e66c57 (patch)
treead74173fbfebe5e04d3a357472cc5161ffd1611f /gcc/tree-vect-loop.c
parent5720a9d5beacb558c1ddccbbfef9f9e4f91b14cf (diff)
downloadgcc-6ddc6a57a74c3a388eb1626e59005f54c6e66c57.zip
gcc-6ddc6a57a74c3a388eb1626e59005f54c6e66c57.tar.gz
gcc-6ddc6a57a74c3a388eb1626e59005f54c6e66c57.tar.bz2
vect: Keep scalar costs around longer
The scalar costs for a loop are fleeting, with only the final single_scalar_iteration_cost being kept for later comparison. This patch replaces single_scalar_iteration_cost with the cost structure, so that (with later patches) it's possible for targets to examine other target-specific cost properties as well. This will be done by passing the scalar costs to hooks where appropriate; targets shouldn't try to read the information directly from loop_vec_infos. gcc/ * tree-vectorizer.h (_loop_vec_info::scalar_costs): New member variable. (_loop_vec_info::single_scalar_iteration_cost): Delete. (LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST): Delete. (vector_costs::total_cost): New function. * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Update after above changes. (_loop_vec_info::~_loop_vec_info): Delete scalar_costs. (vect_compute_single_scalar_iteration_cost): Store the costs in loop_vinfo->scalar_costs. (vect_estimate_min_profitable_iters): Get the scalar cost from loop_vinfo->scalar_costs.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 3d9033f..2153012 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -822,6 +822,7 @@ _loop_vec_info::_loop_vec_info (class loop *loop_in, vec_info_shared *shared)
num_iters_unchanged (NULL_TREE),
num_iters_assumptions (NULL_TREE),
vector_costs (nullptr),
+ scalar_costs (nullptr),
th (0),
versioning_threshold (0),
vectorization_factor (0),
@@ -839,7 +840,6 @@ _loop_vec_info::_loop_vec_info (class loop *loop_in, vec_info_shared *shared)
ivexpr_map (NULL),
scan_map (NULL),
slp_unrolling_factor (1),
- single_scalar_iteration_cost (0),
inner_loop_cost_factor (param_vect_inner_loop_cost_factor),
vectorizable (false),
can_use_partial_vectors_p (param_vect_partial_vector_usage != 0),
@@ -931,6 +931,7 @@ _loop_vec_info::~_loop_vec_info ()
delete ivexpr_map;
delete scan_map;
epilogue_vinfos.release ();
+ delete scalar_costs;
delete vector_costs;
/* When we release an epiloge vinfo that we do not intend to use
@@ -1292,20 +1293,15 @@ vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo)
}
/* Now accumulate cost. */
- vector_costs *target_cost_data = init_cost (loop_vinfo, true);
+ loop_vinfo->scalar_costs = init_cost (loop_vinfo, true);
stmt_info_for_cost *si;
int j;
FOR_EACH_VEC_ELT (LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo),
j, si)
- (void) add_stmt_cost (target_cost_data, si->count,
+ (void) add_stmt_cost (loop_vinfo->scalar_costs, si->count,
si->kind, si->stmt_info, si->vectype,
si->misalign, si->where);
- unsigned prologue_cost = 0, body_cost = 0, epilogue_cost = 0;
- finish_cost (target_cost_data, &prologue_cost, &body_cost,
- &epilogue_cost);
- delete target_cost_data;
- LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST (loop_vinfo)
- = prologue_cost + body_cost + epilogue_cost;
+ loop_vinfo->scalar_costs->finish_cost ();
}
@@ -3868,8 +3864,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
TODO: Consider assigning different costs to different scalar
statements. */
- scalar_single_iter_cost
- = LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST (loop_vinfo);
+ scalar_single_iter_cost = loop_vinfo->scalar_costs->total_cost ();
/* Add additional cost for the peeled instructions in prologue and epilogue
loop. (For fully-masked loops there will be no peeling.)