[vect] Outline code into new function: determine_peel_for_niter
gcc/ChangeLog: 2019-10-17 Andre Vieira <andre.simoesdiasvieira@arm.com> * tree-vect-loop.c (determine_peel_for_niter): New function contained outlined code from ... (vect_analyze_loop_2): ... here. From-SVN: r277103
This commit is contained in:
parent
e400b49192
commit
31b35fd503
@ -1,3 +1,9 @@
|
||||
2019-10-17 Andre Vieira <andre.simoesdiasvieira@arm.com>
|
||||
|
||||
* tree-vect-loop.c (determine_peel_for_niter): New function contained
|
||||
outlined code from ...
|
||||
(vect_analyze_loop_2): ... here.
|
||||
|
||||
2019-10-17 Andre Vieira <andre.simoesdiasvieira@arm.com>
|
||||
|
||||
* tree-vect-loop.c (vect_transform_loop): Move code from here...
|
||||
|
@ -1808,6 +1808,57 @@ vect_dissolve_slp_only_groups (loop_vec_info loop_vinfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Decides whether we need to create an epilogue loop to handle
|
||||
remaining scalar iterations and sets PEELING_FOR_NITERS accordingly. */
|
||||
|
||||
void
|
||||
determine_peel_for_niter (loop_vec_info loop_vinfo)
|
||||
{
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = false;
|
||||
|
||||
unsigned HOST_WIDE_INT const_vf;
|
||||
HOST_WIDE_INT max_niter
|
||||
= likely_max_stmt_executions_int (LOOP_VINFO_LOOP (loop_vinfo));
|
||||
|
||||
unsigned th = LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo);
|
||||
if (!th && LOOP_VINFO_ORIG_LOOP_INFO (loop_vinfo))
|
||||
th = LOOP_VINFO_COST_MODEL_THRESHOLD (LOOP_VINFO_ORIG_LOOP_INFO
|
||||
(loop_vinfo));
|
||||
|
||||
if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
|
||||
/* The main loop handles all iterations. */
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = false;
|
||||
else if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
|
||||
&& LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) >= 0)
|
||||
{
|
||||
/* Work out the (constant) number of iterations that need to be
|
||||
peeled for reasons other than niters. */
|
||||
unsigned int peel_niter = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
|
||||
if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
|
||||
peel_niter += 1;
|
||||
if (!multiple_p (LOOP_VINFO_INT_NITERS (loop_vinfo) - peel_niter,
|
||||
LOOP_VINFO_VECT_FACTOR (loop_vinfo)))
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = true;
|
||||
}
|
||||
else if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo)
|
||||
/* ??? When peeling for gaps but not alignment, we could
|
||||
try to check whether the (variable) niters is known to be
|
||||
VF * N + 1. That's something of a niche case though. */
|
||||
|| LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
|
||||
|| !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&const_vf)
|
||||
|| ((tree_ctz (LOOP_VINFO_NITERS (loop_vinfo))
|
||||
< (unsigned) exact_log2 (const_vf))
|
||||
/* In case of versioning, check if the maximum number of
|
||||
iterations is greater than th. If they are identical,
|
||||
the epilogue is unnecessary. */
|
||||
&& (!LOOP_REQUIRES_VERSIONING (loop_vinfo)
|
||||
|| ((unsigned HOST_WIDE_INT) max_niter
|
||||
> (th / const_vf) * const_vf))))
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = true;
|
||||
}
|
||||
|
||||
|
||||
/* Function vect_analyze_loop_2.
|
||||
|
||||
Apply a set of analyses on LOOP, and create a loop_vec_info struct
|
||||
@ -1935,7 +1986,6 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, unsigned *n_stmts)
|
||||
vect_compute_single_scalar_iteration_cost (loop_vinfo);
|
||||
|
||||
poly_uint64 saved_vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
|
||||
unsigned th;
|
||||
|
||||
/* Check the SLP opportunities in the loop, analyze and build SLP trees. */
|
||||
ok = vect_analyze_slp (loop_vinfo, *n_stmts);
|
||||
@ -1975,9 +2025,6 @@ start_over:
|
||||
LOOP_VINFO_INT_NITERS (loop_vinfo));
|
||||
}
|
||||
|
||||
HOST_WIDE_INT max_niter
|
||||
= likely_max_stmt_executions_int (LOOP_VINFO_LOOP (loop_vinfo));
|
||||
|
||||
/* Analyze the alignment of the data-refs in the loop.
|
||||
Fail if a data reference is found that cannot be vectorized. */
|
||||
|
||||
@ -2081,42 +2128,7 @@ start_over:
|
||||
return opt_result::failure_at (vect_location,
|
||||
"Loop costings not worthwhile.\n");
|
||||
|
||||
/* Decide whether we need to create an epilogue loop to handle
|
||||
remaining scalar iterations. */
|
||||
th = LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo);
|
||||
|
||||
unsigned HOST_WIDE_INT const_vf;
|
||||
if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
|
||||
/* The main loop handles all iterations. */
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = false;
|
||||
else if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
|
||||
&& LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) >= 0)
|
||||
{
|
||||
/* Work out the (constant) number of iterations that need to be
|
||||
peeled for reasons other than niters. */
|
||||
unsigned int peel_niter = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
|
||||
if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
|
||||
peel_niter += 1;
|
||||
if (!multiple_p (LOOP_VINFO_INT_NITERS (loop_vinfo) - peel_niter,
|
||||
LOOP_VINFO_VECT_FACTOR (loop_vinfo)))
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = true;
|
||||
}
|
||||
else if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo)
|
||||
/* ??? When peeling for gaps but not alignment, we could
|
||||
try to check whether the (variable) niters is known to be
|
||||
VF * N + 1. That's something of a niche case though. */
|
||||
|| LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
|
||||
|| !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&const_vf)
|
||||
|| ((tree_ctz (LOOP_VINFO_NITERS (loop_vinfo))
|
||||
< (unsigned) exact_log2 (const_vf))
|
||||
/* In case of versioning, check if the maximum number of
|
||||
iterations is greater than th. If they are identical,
|
||||
the epilogue is unnecessary. */
|
||||
&& (!LOOP_REQUIRES_VERSIONING (loop_vinfo)
|
||||
|| ((unsigned HOST_WIDE_INT) max_niter
|
||||
> (th / const_vf) * const_vf))))
|
||||
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = true;
|
||||
|
||||
determine_peel_for_niter (loop_vinfo);
|
||||
/* If an epilogue loop is required make sure we can create one. */
|
||||
if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
|
||||
|| LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo))
|
||||
|
Loading…
Reference in New Issue
Block a user