summaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-17 13:19:46 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-17 13:19:46 +0000
commitb4f314ea97f04620d290f3ae25d831f46692864f (patch)
treee99df6f0f35dce95dacd7a91b0242e81462a0860 /gcc/tree-vect-loop.c
parent644412e1c29a2984b1b37656c18fe9f33791eff1 (diff)
parent7de380af566c189319d706d3b4ab04e32ecc5d90 (diff)
downloadgcc-b4f314ea97f04620d290f3ae25d831f46692864f.tar.gz
Merge from trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@209485 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f959da62320..1f6ac1a348b 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -933,6 +933,7 @@ new_loop_vec_info (struct loop *loop)
LOOP_VINFO_NITERS (res) = NULL;
LOOP_VINFO_NITERS_UNCHANGED (res) = NULL;
LOOP_VINFO_COST_MODEL_MIN_ITERS (res) = 0;
+ LOOP_VINFO_COST_MODEL_THRESHOLD (res) = 0;
LOOP_VINFO_VECTORIZABLE_P (res) = 0;
LOOP_VINFO_PEELING_FOR_ALIGNMENT (res) = 0;
LOOP_VINFO_VECT_FACTOR (res) = 0;
@@ -1579,6 +1580,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
|| min_profitable_iters > min_scalar_loop_bound))
th = (unsigned) min_profitable_iters;
+ LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) = th;
+
if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
&& LOOP_VINFO_INT_NITERS (loop_vinfo) <= th)
{
@@ -1625,6 +1628,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
bool ok, slp = false;
int max_vf = MAX_VECTORIZATION_FACTOR;
int min_vf = 2;
+ unsigned int th;
+ unsigned int n_stmts = 0;
/* Find all data references in the loop (which correspond to vdefs/vuses)
and analyze their evolution in the loop. Also adjust the minimal
@@ -1633,7 +1638,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
FORNOW: Handle only simple, array references, which
alignment can be forced, and aligned pointer-references. */
- ok = vect_analyze_data_refs (loop_vinfo, NULL, &min_vf);
+ ok = vect_analyze_data_refs (loop_vinfo, NULL, &min_vf, &n_stmts);
if (!ok)
{
if (dump_enabled_p ())
@@ -1743,7 +1748,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
}
/* Check the SLP opportunities in the loop, analyze and build SLP trees. */
- ok = vect_analyze_slp (loop_vinfo, NULL);
+ ok = vect_analyze_slp (loop_vinfo, NULL, n_stmts);
if (ok)
{
/* Decide which possible SLP instances to SLP. */
@@ -1769,6 +1774,10 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
/* Decide whether we need to create an epilogue loop to handle
remaining scalar iterations. */
+ th = ((LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) + 1)
+ / LOOP_VINFO_VECT_FACTOR (loop_vinfo))
+ * LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+
if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
&& LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0)
{
@@ -1779,7 +1788,14 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
}
else if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo)
|| (tree_ctz (LOOP_VINFO_NITERS (loop_vinfo))
- < (unsigned)exact_log2 (LOOP_VINFO_VECT_FACTOR (loop_vinfo))))
+ < (unsigned)exact_log2 (LOOP_VINFO_VECT_FACTOR (loop_vinfo))
+ /* 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_FOR_ALIAS (loop_vinfo)
+ && !LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo))
+ || (unsigned HOST_WIDE_INT)max_stmt_executions_int
+ (LOOP_VINFO_LOOP (loop_vinfo)) > th)))
LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo) = true;
/* If an epilogue loop is required make sure we can create one. */
@@ -2971,7 +2987,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
/* vector version will never be profitable. */
else
{
- if (LOOP_VINFO_LOOP (loop_vinfo)->force_vect)
+ if (LOOP_VINFO_LOOP (loop_vinfo)->force_vectorize)
warning_at (vect_location, OPT_Wopenmp_simd, "vectorization "
"did not happen for a simd loop");
@@ -3936,8 +3952,12 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
/* Set phi nodes arguments. */
FOR_EACH_VEC_ELT (reduction_phis, i, phi)
{
- tree vec_init_def = vec_initial_defs[i];
- tree def = vect_defs[i];
+ tree vec_init_def, def;
+ gimple_seq stmts;
+ vec_init_def = force_gimple_operand (vec_initial_defs[i], &stmts,
+ true, NULL_TREE);
+ gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+ def = vect_defs[i];
for (j = 0; j < ncopies; j++)
{
/* Set the loop-entry arg of the reduction-phi. */
@@ -5775,9 +5795,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
by our caller. If the threshold makes all loops profitable that
run at least the vectorization factor number of times checking
is pointless, too. */
- th = ((PARAM_VALUE (PARAM_MIN_VECT_LOOP_BOUND)
- * LOOP_VINFO_VECT_FACTOR (loop_vinfo)) - 1);
- th = MAX (th, LOOP_VINFO_COST_MODEL_MIN_ITERS (loop_vinfo));
+ th = LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo);
if (th >= LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 1
&& !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
{