From: Robin Dapp <[email protected]>
This patch adjusts niter-condition costing. Instead of just one
vector statements, it counts the number of ANDed terms and costs
that many scalar statements.
gcc/ChangeLog:
* tree-vect-loop.cc (vect_estimate_min_profitable_iters): Adjust
niter condition costing.
---
gcc/tree-vect-loop.cc | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3908cad5714..7bcc02535d4 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -4160,8 +4160,21 @@ vect_estimate_min_profitable_iters (loop_vec_info
loop_vinfo,
/* Requires loop versioning with niter checks. */
if (LOOP_REQUIRES_VERSIONING_FOR_NITERS (loop_vinfo))
{
+ tree assum = LOOP_VINFO_NITERS_ASSUMPTIONS (loop_vinfo);
+
+ /* Count the number of &&s in the assumptions. */
+ auto count_conditions = [](tree *t, int *, void *nconditions) -> tree
+ {
+ if (TREE_CODE (*t) == TRUTH_AND_EXPR)
+ (*(int *) nconditions)++;
+ return NULL_TREE;
+ };
+
+ int nconditions = 0;
+ walk_tree_without_duplicates (&assum, count_conditions, &nconditions);
+
/* FIXME: Make cost depend on complexity of individual check. */
- (void) add_stmt_cost (target_cost_data, 1, vector_stmt,
+ (void) add_stmt_cost (target_cost_data, nconditions, scalar_stmt,
NULL, NULL, NULL_TREE, 0, vect_prologue);
if (dump_enabled_p ())
dump_printf (MSG_NOTE,
--
2.54.0