diff options
author | Richard Biener <rguenther@suse.de> | 2025-07-29 09:20:42 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2025-07-31 08:31:17 +0200 |
commit | fb59c5719c17a04ecfd58b5e566eccd6d2ac583a (patch) | |
tree | 64c493c411d303abb31754a7b0a48e76fef88936 /gcc | |
parent | da88f9bd9e30eb743132734d71c62ebb9c42b11e (diff) | |
download | gcc-fb59c5719c17a04ecfd58b5e566eccd6d2ac583a.zip gcc-fb59c5719c17a04ecfd58b5e566eccd6d2ac583a.tar.gz gcc-fb59c5719c17a04ecfd58b5e566eccd6d2ac583a.tar.bz2 |
Avoid passing vectype != NULL when costing scalar IL
The following makes sure to not leak a set vectype on a stmt when
doing scalar IL costing as this can confuse vector cost models
which do not look at m_costing_for_scalar most of the time.
* tree-vectorizer.h (vector_costs::costing_for_scalar): New
accessor.
(add_stmt_cost): For scalar costing force vectype to NULL.
Verify we do not pass in a SLP node.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-vectorizer.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index e1900279..222a723 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1718,6 +1718,7 @@ public: unsigned int total_cost () const; unsigned int suggested_unroll_factor () const; machine_mode suggested_epilogue_mode (int &masked) const; + bool costing_for_scalar () const { return m_costing_for_scalar; } protected: unsigned int record_stmt_cost (stmt_vec_info, vect_cost_model_location, @@ -2000,6 +2001,13 @@ add_stmt_cost (vector_costs *costs, int count, tree vectype, int misalign, enum vect_cost_model_location where) { + /* Even though a vector type might be set on stmt do not pass that on when + costing the scalar IL. A SLP node shouldn't have been recorded. */ + if (costs->costing_for_scalar ()) + { + vectype = NULL_TREE; + gcc_checking_assert (node == NULL); + } unsigned cost = costs->add_stmt_cost (count, kind, stmt_info, node, vectype, misalign, where); if (dump_file && (dump_flags & TDF_DETAILS)) |