diff mbox series

[RFC,5/5] vect: Also cost gconds for scalar

Message ID Zx+mBN9vS+bJgSme@arm.com
State New
Headers show
Series vect: Force peeling for alignment to handle more early break loops | expand

Commit Message

Alex Coplan Oct. 28, 2024, 2:56 p.m. UTC
Currently we only cost gconds for the vector loop while we omit costing
them when analyzing the scalar loop; this unfairly penalizes the vector
loop in the case of loops with early exits.

This (together with the previous patches) enables us to vectorize
std::find with 64-bit element sizes.

gcc/ChangeLog:

	* tree-vect-loop.cc (vect_compute_single_scalar_iteration_cost):
	Don't skip over gconds.
---
 gcc/tree-vect-loop.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Richard Biener Oct. 29, 2024, 12:44 p.m. UTC | #1
On Mon, 28 Oct 2024, Alex Coplan wrote:

> Currently we only cost gconds for the vector loop while we omit costing
> them when analyzing the scalar loop; this unfairly penalizes the vector
> loop in the case of loops with early exits.
> 
> This (together with the previous patches) enables us to vectorize
> std::find with 64-bit element sizes.

OK.

Thanks,
Richard.

> gcc/ChangeLog:
> 
> 	* tree-vect-loop.cc (vect_compute_single_scalar_iteration_cost):
> 	Don't skip over gconds.
> ---
>  gcc/tree-vect-loop.cc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
>
Richard Biener Oct. 29, 2024, 12:45 p.m. UTC | #2
On Tue, 29 Oct 2024, Richard Biener wrote:

> On Mon, 28 Oct 2024, Alex Coplan wrote:
> 
> > Currently we only cost gconds for the vector loop while we omit costing
> > them when analyzing the scalar loop; this unfairly penalizes the vector
> > loop in the case of loops with early exits.
> > 
> > This (together with the previous patches) enables us to vectorize
> > std::find with 64-bit element sizes.
> 
> OK.

Ah, wait - but we're now costing the scalar IV gcond but we're not
costing the vector (scalar) IV gcond.  So you want to exempt the
main IV gcond here.

Richard.

> Thanks,
> Richard.
> 
> > gcc/ChangeLog:
> > 
> > 	* tree-vect-loop.cc (vect_compute_single_scalar_iteration_cost):
> > 	Don't skip over gconds.
> > ---
> >  gcc/tree-vect-loop.cc | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > 
> 
>
diff mbox series

Patch

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index b8e155b90f8..5e5825c6593 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -1688,7 +1688,9 @@  vect_compute_single_scalar_iteration_cost (loop_vec_info loop_vinfo)
 	  gimple *stmt = gsi_stmt (si);
 	  stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (stmt);
 
-          if (!is_gimple_assign (stmt) && !is_gimple_call (stmt))
+	  if (!is_gimple_assign (stmt)
+	      && !is_gimple_call (stmt)
+	      && !is_a<gcond *> (stmt))
             continue;
 
           /* Skip stmts that are not vectorized inside the loop.  */