num_iters_unchanged (NULL_TREE),
num_iters_assumptions (NULL_TREE),
vector_costs (nullptr),
+ scalar_costs (nullptr),
th (0),
versioning_threshold (0),
vectorization_factor (0),
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),
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
}
/* 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 ();
}
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.)
/* The cost of the vector code. */
class vector_costs *vector_costs;
+ /* The cost of the scalar code. */
+ class vector_costs *scalar_costs;
+
/* Threshold of number of iterations below which vectorization will not be
performed. It is calculated from MIN_PROFITABLE_ITERS and
param_min_vect_loop_bound. */
applied to the loop, i.e., no unrolling is needed, this is 1. */
poly_uint64 slp_unrolling_factor;
- /* Cost of a single scalar iteration. */
- int single_scalar_iteration_cost;
-
/* The factor used to over weight those statements in an inner loop
relative to the loop being vectorized. */
unsigned int inner_loop_cost_factor;
#define LOOP_VINFO_SCALAR_LOOP_SCALING(L) (L)->scalar_loop_scaling
#define LOOP_VINFO_HAS_MASK_STORE(L) (L)->has_mask_store
#define LOOP_VINFO_SCALAR_ITERATION_COST(L) (L)->scalar_cost_vec
-#define LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST(L) (L)->single_scalar_iteration_cost
#define LOOP_VINFO_ORIG_LOOP_INFO(L) (L)->orig_loop_info
#define LOOP_VINFO_SIMD_IF_COND(L) (L)->simd_if_cond
#define LOOP_VINFO_INNER_LOOP_COST_FACTOR(L) (L)->inner_loop_cost_factor
unsigned int body_cost () const;
unsigned int epilogue_cost () const;
unsigned int outside_cost () const;
+ unsigned int total_cost () const;
protected:
unsigned int record_stmt_cost (stmt_vec_info, vect_cost_model_location,
return prologue_cost () + epilogue_cost ();
}
+/* Return the cost of the prologue, body and epilogue code
+ (in abstract units). */
+
+inline unsigned int
+vector_costs::total_cost () const
+{
+ return body_cost () + outside_cost ();
+}
+
#define VECT_MAX_COST 1000
/* The maximum number of intermediate steps required in multi-step type