aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-22 09:58:08 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2019-11-22 09:58:08 +0000
commit34abd1cf24fcb5cfca2af0029d0de2701cd56944 (patch)
tree0381a84acd6f11dbd5c16f42958d9abbe1b274ce
parent28aa9d346864b1e6de6a0b7bd271d31b382e0aa5 (diff)
Move EXTRACT_LAST_REDUCTION costing to vectorizable_condition
gcc.target/aarch64/sve/clastb_[57].c started failing after the increase in the cost of vec_to_scalar (r278452). The problem is that we were double-counting the cost of the CLASTB: once in vect_model_reduction_cost as a vec_to_scalar and once in vectorizable_condition as a plain vector_stmt. Based on the TODO above vect_model_reduction_cost, I think the preferred long-term direction is for vectorizable_* to cost these things itself, so that's what the patch does (for this one case only). 2019-11-22 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-stmts.c (vect_model_simple_cost): Take an optional vect_cost_for_stmt. (vectorizable_condition): Calculate the cost of EXTRACT_LAST_REDUCTION here rather than... * tree-vect-loop.c (vect_model_reduction_cost): ...here. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278611 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/tree-vect-loop.c7
-rw-r--r--gcc/tree-vect-stmts.c26
3 files changed, 28 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 986324acba3..bdd0fc529b7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2019-11-22 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree-vect-stmts.c (vect_model_simple_cost): Take an optional
+ vect_cost_for_stmt.
+ (vectorizable_condition): Calculate the cost of EXTRACT_LAST_REDUCTION
+ here rather than...
+ * tree-vect-loop.c (vect_model_reduction_cost): ...here.
+
2019-11-22 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.md (bic_f): Use cc_set_register predicate.
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index e4a87e7afe3..ca8c8187f60 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3924,8 +3924,11 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, internal_fn reduc_fn,
code = gimple_assign_rhs_code (orig_stmt_info->stmt);
- if (reduction_type == EXTRACT_LAST_REDUCTION
- || reduction_type == FOLD_LEFT_REDUCTION)
+ if (reduction_type == EXTRACT_LAST_REDUCTION)
+ /* No extra instructions are needed in the prologue. The loop body
+ operations are costed in vectorizable_condition. */
+ inside_cost = 0;
+ else if (reduction_type == FOLD_LEFT_REDUCTION)
{
/* No extra instructions needed in the prologue. */
prologue_cost = 0;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 65c649d66f7..6890837bf9f 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -860,7 +860,8 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
enum vect_def_type *dt,
int ndts,
slp_tree node,
- stmt_vector_for_cost *cost_vec)
+ stmt_vector_for_cost *cost_vec,
+ vect_cost_for_stmt kind = vector_stmt)
{
int inside_cost = 0, prologue_cost = 0;
@@ -907,7 +908,7 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
}
/* Pass the inside-of-loop statements to the target-specific cost model. */
- inside_cost += record_stmt_cost (cost_vec, ncopies, vector_stmt,
+ inside_cost += record_stmt_cost (cost_vec, ncopies, kind,
stmt_info, 0, vect_body);
if (dump_enabled_p ())
@@ -10084,15 +10085,18 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
return false;
}
}
- if (expand_vec_cond_expr_p (vectype, comp_vectype,
- cond_code))
- {
- STMT_VINFO_TYPE (stmt_info) = condition_vec_info_type;
- vect_model_simple_cost (stmt_info, ncopies, dts, ndts, slp_node,
- cost_vec);
- return true;
- }
- return false;
+
+ vect_cost_for_stmt kind = vector_stmt;
+ if (reduction_type == EXTRACT_LAST_REDUCTION)
+ /* Count one reduction-like operation per vector. */
+ kind = vec_to_scalar;
+ else if (!expand_vec_cond_expr_p (vectype, comp_vectype, cond_code))
+ return false;
+
+ STMT_VINFO_TYPE (stmt_info) = condition_vec_info_type;
+ vect_model_simple_cost (stmt_info, ncopies, dts, ndts, slp_node,
+ cost_vec, kind);
+ return true;
}
/* Transform. */