[1/2] make vect_finish_stmt_generation work w/o stmt_vec_info

Message ID nycvar.YFH.7.76.2005271551460.4397@zhemvz.fhfr.qr
State New
Headers show
Series
  • [1/2] make vect_finish_stmt_generation work w/o stmt_vec_info
Related show

Commit Message

Richard Biener May 27, 2020, 1:51 p.m.
This makes the call chain below vec_init_vector happy with a NULL
stmt_vec_info which is used as "context".

2020-05-27  Richard Biener  <rguenther@suse.de>

	* tree-vect-stmts.c (vect_finish_stmt_generation_1):
	Conditionalize stmt_info use, assert the new stmt cannot throw
	when not specified.
	(vect_finish_stmt_generation): Adjust assert.
---
 gcc/tree-vect-stmts.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

-- 
2.26.1

Comments

Richard Sandiford May 27, 2020, 3:40 p.m. | #1
Richard Biener <rguenther@suse.de> writes:
> This makes the call chain below vec_init_vector happy with a NULL

> stmt_vec_info which is used as "context".

>

> 2020-05-27  Richard Biener  <rguenther@suse.de>

>

> 	* tree-vect-stmts.c (vect_finish_stmt_generation_1):

> 	Conditionalize stmt_info use, assert the new stmt cannot throw

> 	when not specified.

> 	(vect_finish_stmt_generation): Adjust assert.


Wasn't sure from this patch in isolation: when's it valid to pass a null
stmt_info?  Felt weird that we suddenly needed this now, when we already
have so many callers that follow the existing interface.

Or is this because you want to remove the stmt_info argument entirely
at some point, and this is a step towards that?

Thanks,
Richard

> ---

>  gcc/tree-vect-stmts.c | 21 +++++++++++++--------

>  1 file changed, 13 insertions(+), 8 deletions(-)

>

> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c

> index 35043ecd0f9..901999be058 100644

> --- a/gcc/tree-vect-stmts.c

> +++ b/gcc/tree-vect-stmts.c

> @@ -1668,14 +1668,19 @@ vect_finish_stmt_generation_1 (vec_info *vinfo,

>    if (dump_enabled_p ())

>      dump_printf_loc (MSG_NOTE, vect_location, "add new stmt: %G", vec_stmt);

>  

> -  gimple_set_location (vec_stmt, gimple_location (stmt_info->stmt));

> +  if (stmt_info)

> +    {

> +      gimple_set_location (vec_stmt, gimple_location (stmt_info->stmt));

>  

> -  /* While EH edges will generally prevent vectorization, stmt might

> -     e.g. be in a must-not-throw region.  Ensure newly created stmts

> -     that could throw are part of the same region.  */

> -  int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);

> -  if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))

> -    add_stmt_to_eh_lp (vec_stmt, lp_nr);

> +      /* While EH edges will generally prevent vectorization, stmt might

> +	 e.g. be in a must-not-throw region.  Ensure newly created stmts

> +	 that could throw are part of the same region.  */

> +      int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);

> +      if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))

> +	add_stmt_to_eh_lp (vec_stmt, lp_nr);

> +    }

> +  else

> +    gcc_assert (!stmt_could_throw_p (cfun, vec_stmt));

>  

>    return vec_stmt_info;

>  }

> @@ -1705,7 +1710,7 @@ vect_finish_stmt_generation (vec_info *vinfo,

>  			     stmt_vec_info stmt_info, gimple *vec_stmt,

>  			     gimple_stmt_iterator *gsi)

>  {

> -  gcc_assert (gimple_code (stmt_info->stmt) != GIMPLE_LABEL);

> +  gcc_assert (!stmt_info || gimple_code (stmt_info->stmt) != GIMPLE_LABEL);

>  

>    if (!gsi_end_p (*gsi)

>        && gimple_has_mem_ops (vec_stmt))
Richard Biener May 27, 2020, 4:14 p.m. | #2
On May 27, 2020 5:40:30 PM GMT+02:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>Richard Biener <rguenther@suse.de> writes:

>> This makes the call chain below vec_init_vector happy with a NULL

>> stmt_vec_info which is used as "context".

>>

>> 2020-05-27  Richard Biener  <rguenther@suse.de>

>>

>> 	* tree-vect-stmts.c (vect_finish_stmt_generation_1):

>> 	Conditionalize stmt_info use, assert the new stmt cannot throw

>> 	when not specified.

>> 	(vect_finish_stmt_generation): Adjust assert.

>

>Wasn't sure from this patch in isolation: when's it valid to pass a

>null

>stmt_info?  Felt weird that we suddenly needed this now, when we

>already

>have so many callers that follow the existing interface.


It should always, but there's this weird EH thing there for which I need to find a testcase. 

>Or is this because you want to remove the stmt_info argument entirely

>at some point, and this is a step towards that?


Yes. I don't have a stmt for each SLP node anymore... 

Richard. 

>Thanks,

>Richard

>

>> ---

>>  gcc/tree-vect-stmts.c | 21 +++++++++++++--------

>>  1 file changed, 13 insertions(+), 8 deletions(-)

>>

>> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c

>> index 35043ecd0f9..901999be058 100644

>> --- a/gcc/tree-vect-stmts.c

>> +++ b/gcc/tree-vect-stmts.c

>> @@ -1668,14 +1668,19 @@ vect_finish_stmt_generation_1 (vec_info

>*vinfo,

>>    if (dump_enabled_p ())

>>      dump_printf_loc (MSG_NOTE, vect_location, "add new stmt: %G",

>vec_stmt);

>>  

>> -  gimple_set_location (vec_stmt, gimple_location (stmt_info->stmt));

>> +  if (stmt_info)

>> +    {

>> +      gimple_set_location (vec_stmt, gimple_location

>(stmt_info->stmt));

>>  

>> -  /* While EH edges will generally prevent vectorization, stmt might

>> -     e.g. be in a must-not-throw region.  Ensure newly created stmts

>> -     that could throw are part of the same region.  */

>> -  int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);

>> -  if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))

>> -    add_stmt_to_eh_lp (vec_stmt, lp_nr);

>> +      /* While EH edges will generally prevent vectorization, stmt

>might

>> +	 e.g. be in a must-not-throw region.  Ensure newly created stmts

>> +	 that could throw are part of the same region.  */

>> +      int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);

>> +      if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))

>> +	add_stmt_to_eh_lp (vec_stmt, lp_nr);

>> +    }

>> +  else

>> +    gcc_assert (!stmt_could_throw_p (cfun, vec_stmt));

>>  

>>    return vec_stmt_info;

>>  }

>> @@ -1705,7 +1710,7 @@ vect_finish_stmt_generation (vec_info *vinfo,

>>  			     stmt_vec_info stmt_info, gimple *vec_stmt,

>>  			     gimple_stmt_iterator *gsi)

>>  {

>> -  gcc_assert (gimple_code (stmt_info->stmt) != GIMPLE_LABEL);

>> +  gcc_assert (!stmt_info || gimple_code (stmt_info->stmt) !=

>GIMPLE_LABEL);

>>  

>>    if (!gsi_end_p (*gsi)

>>        && gimple_has_mem_ops (vec_stmt))

Patch

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 35043ecd0f9..901999be058 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1668,14 +1668,19 @@  vect_finish_stmt_generation_1 (vec_info *vinfo,
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location, "add new stmt: %G", vec_stmt);
 
-  gimple_set_location (vec_stmt, gimple_location (stmt_info->stmt));
+  if (stmt_info)
+    {
+      gimple_set_location (vec_stmt, gimple_location (stmt_info->stmt));
 
-  /* While EH edges will generally prevent vectorization, stmt might
-     e.g. be in a must-not-throw region.  Ensure newly created stmts
-     that could throw are part of the same region.  */
-  int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);
-  if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))
-    add_stmt_to_eh_lp (vec_stmt, lp_nr);
+      /* While EH edges will generally prevent vectorization, stmt might
+	 e.g. be in a must-not-throw region.  Ensure newly created stmts
+	 that could throw are part of the same region.  */
+      int lp_nr = lookup_stmt_eh_lp (stmt_info->stmt);
+      if (lp_nr != 0 && stmt_could_throw_p (cfun, vec_stmt))
+	add_stmt_to_eh_lp (vec_stmt, lp_nr);
+    }
+  else
+    gcc_assert (!stmt_could_throw_p (cfun, vec_stmt));
 
   return vec_stmt_info;
 }
@@ -1705,7 +1710,7 @@  vect_finish_stmt_generation (vec_info *vinfo,
 			     stmt_vec_info stmt_info, gimple *vec_stmt,
 			     gimple_stmt_iterator *gsi)
 {
-  gcc_assert (gimple_code (stmt_info->stmt) != GIMPLE_LABEL);
+  gcc_assert (!stmt_info || gimple_code (stmt_info->stmt) != GIMPLE_LABEL);
 
   if (!gsi_end_p (*gsi)
       && gimple_has_mem_ops (vec_stmt))