diff mbox series

[2/2,v2] rs6000: Guard density_test only for vector version

Message ID 8e75f918-a985-0d2e-ed2b-26f4c72ff74d@linux.ibm.com
State New
Headers show
Series rs6000: Make density_test only for vector version | expand

Commit Message

Kewen.Lin May 8, 2021, 8:12 a.m. UTC
Hi,

v1: https://gcc.gnu.org/pipermail/gcc-patches/2021-May/569790.html

This is the updated version with one new parameter costing_for_scalar
passed by init_cost hook, instead of checking the passed data point
identity.

Bootstrapped/regtested on powerpc64le-linux-gnu P9.

Is it ok for trunk?

BR,
Kewen
-----
gcc/ChangeLog:

	* config/rs6000/rs6000.c (struct rs6000_cost_data): New member
	costing_for_scalar.
	(rs6000_density_test): Early return if costing_for_scalar is true.
	(rs6000_init_cost): Init costing_for_scalar of rs6000_cost_data.
---
 gcc/config/rs6000/rs6000.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Segher Boessenkool May 10, 2021, 8:12 p.m. UTC | #1
Hi!

On Sat, May 08, 2021 at 04:12:18PM +0800, Kewen.Lin wrote:
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -5234,6 +5234,8 @@ typedef struct _rs6000_cost_data
>    /* For each vectorized loop, this var holds TRUE iff a non-memory vector
>       instruction is needed by the vectorization.  */
>    bool vect_nonmem;
> +  /* Indicates costing for the scalar version of a loop or block.  */
> +  bool costing_for_scalar;
>  } rs6000_cost_data;

"... this is costing for ..."?

> @@ -5255,6 +5257,12 @@ rs6000_density_test (rs6000_cost_data *data)
>    int vec_cost = data->cost[vect_body], not_vec_cost = 0;
>    int i, density_pct;
>  
> +  /* This density test only cares about the cost of vector version of the
> +     loop, early return if it's costing for the scalar version (namely
> +     computing single scalar iteration cost).  */
> +  if (data->costing_for_scalar)
> +    return;

"..., so immediately return if we are passed costing for ..."?

The patch is okay for trunk with those or similar changes.  Thanks!


Segher
Kewen.Lin May 11, 2021, 7:20 a.m. UTC | #2
Hi Segher,

on 2021/5/11 上午4:12, Segher Boessenkool wrote:
> Hi!
> 
> On Sat, May 08, 2021 at 04:12:18PM +0800, Kewen.Lin wrote:
>> --- a/gcc/config/rs6000/rs6000.c
>> +++ b/gcc/config/rs6000/rs6000.c
>> @@ -5234,6 +5234,8 @@ typedef struct _rs6000_cost_data
>>    /* For each vectorized loop, this var holds TRUE iff a non-memory vector
>>       instruction is needed by the vectorization.  */
>>    bool vect_nonmem;
>> +  /* Indicates costing for the scalar version of a loop or block.  */
>> +  bool costing_for_scalar;
>>  } rs6000_cost_data;
> 
> "... this is costing for ..."?
> 
>> @@ -5255,6 +5257,12 @@ rs6000_density_test (rs6000_cost_data *data)
>>    int vec_cost = data->cost[vect_body], not_vec_cost = 0;
>>    int i, density_pct;
>>  
>> +  /* This density test only cares about the cost of vector version of the
>> +     loop, early return if it's costing for the scalar version (namely
>> +     computing single scalar iteration cost).  */
>> +  if (data->costing_for_scalar)
>> +    return;
> 
> "..., so immediately return if we are passed costing for ..."?
> 
> The patch is okay for trunk with those or similar changes.  Thanks!
> 
> 

Thanks for the review!

Committed in r12-705 with the requested comment changes.

BR,
Kewen
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 88f16b909a3..4981597a10e 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5234,6 +5234,8 @@  typedef struct _rs6000_cost_data
   /* For each vectorized loop, this var holds TRUE iff a non-memory vector
      instruction is needed by the vectorization.  */
   bool vect_nonmem;
+  /* Indicates costing for the scalar version of a loop or block.  */
+  bool costing_for_scalar;
 } rs6000_cost_data;
 
 /* Test for likely overcommitment of vector hardware resources.  If a
@@ -5255,6 +5257,12 @@  rs6000_density_test (rs6000_cost_data *data)
   int vec_cost = data->cost[vect_body], not_vec_cost = 0;
   int i, density_pct;
 
+  /* This density test only cares about the cost of vector version of the
+     loop, early return if it's costing for the scalar version (namely
+     computing single scalar iteration cost).  */
+  if (data->costing_for_scalar)
+    return;
+
   for (i = 0; i < nbbs; i++)
     {
       basic_block bb = bbs[i];
@@ -5292,7 +5300,7 @@  rs6000_density_test (rs6000_cost_data *data)
 /* Implement targetm.vectorize.init_cost.  */
 
 static void *
-rs6000_init_cost (struct loop *loop_info, bool)
+rs6000_init_cost (struct loop *loop_info, bool costing_for_scalar)
 {
   rs6000_cost_data *data = XNEW (struct _rs6000_cost_data);
   data->loop_info = loop_info;
@@ -5300,6 +5308,7 @@  rs6000_init_cost (struct loop *loop_info, bool)
   data->cost[vect_body]     = 0;
   data->cost[vect_epilogue] = 0;
   data->vect_nonmem = false;
+  data->costing_for_scalar = costing_for_scalar;
   return data;
 }