From 61fc5e098e76c9809f35f449a70c9c8d74773d9d Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 18 Feb 2022 11:34:52 +0100 Subject: tree-optimization/104582 - Simplify vectorizer cost API and fixes This simplifies the vectorizer cost API by providing overloads to add_stmt_cost and record_stmt_cost suitable for scalar stmt and branch stmt costing which do not need information like a vector type or alignment. It also fixes two mistakes where costs for versioning tests were recorded as vector stmt rather than scalar stmt. This is a first patch to simplify the actual fix for PR104582. 2022-02-18 Richard Biener PR tree-optimization/104582 * tree-vectorizer.h (add_stmt_cost): New overload. (record_stmt_cost): Likewise. * tree-vect-loop.cc (vect_compute_single_scalar_iteration_cost): Use add_stmt_costs. (vect_get_known_peeling_cost): Use new overloads. (vect_estimate_min_profitable_iters): Likewise. Consistently use scalar_stmt for costing versioning checks. * tree-vect-stmts.cc (record_stmt_cost): New overload. --- gcc/tree-vectorizer.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index ddd0637..da99f28 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1762,6 +1762,15 @@ add_stmt_cost (vector_costs *costs, int count, return cost; } +static inline unsigned +add_stmt_cost (vector_costs *costs, int count, enum vect_cost_for_stmt kind, + enum vect_cost_model_location where) +{ + gcc_assert (kind == cond_branch_taken || kind == cond_branch_not_taken + || kind == scalar_stmt); + return add_stmt_cost (costs, count, kind, NULL, NULL_TREE, 0, where); +} + /* Alias targetm.vectorize.add_stmt_cost. */ static inline unsigned @@ -2120,6 +2129,9 @@ extern bool supportable_narrowing_operation (enum tree_code, tree, tree, extern unsigned record_stmt_cost (stmt_vector_for_cost *, int, enum vect_cost_for_stmt, stmt_vec_info, tree, int, enum vect_cost_model_location); +extern unsigned record_stmt_cost (stmt_vector_for_cost *, int, + enum vect_cost_for_stmt, + enum vect_cost_model_location); /* Overload of record_stmt_cost with VECTYPE derived from STMT_INFO. */ -- cgit v1.1