Hi,

This patch comes from me getting confused about gimple dumps from vect.
Specifically, while seemingly not causing any issues I found the conversion of
the IV step from an integral step, to a pointer value, and then to sizetype
misleading. By the look of things create_iv already has the infrastructure to
support a pointer type base with integral mode step, so this seemed a nice
clean up?

In conversation with Richard S offline he suggested this may be like this
as PLUS_EXPR requires match argument type, but seemingly we have dropped that
requirement for create_iv as I think the use at gcc/tree-vect-stmts.cc:8683
has non-matching types?

Thoughts? Is it worth changing the code argument of create_iv to an UP/DOWN
enum instead if this is the intended use case?

Bootstrapped and reg-tested on aarch64 and x86_64.

Thanks,
Alfie

-- >8 --

Removes `fold_convert (aggr_ptr_type, STEP)` when using create_iv.

This was previously constructing statements like:
```
unsigned int _49;
vector([4,4]) int * _50;
sizetype _51;
vector([4,4]) int * vectp_x.6;
...
_50 = (vector([4,4]) int *) _49;
_51 = (sizetype) _50;
...
vectp_x.6_48 = vectp_x.6_47 + _51;
```

And instead creates:
```
unsigned int _49;
sizetype _50;
vector([4,4]) int * vectp_x.6;
...
_50 = (sizetype) _49;
...
vectp_x.6_48 = vectp_x.6_47 + _50;
```

As create_iv already has the logic to handle a pointer mode base and an integer
mode var this seems a more natural expression of this.

gcc/ChangeLog:

        * tree-vect-data-refs.cc (vect_create_data_ref_ptr):
---
 gcc/tree-vect-data-refs.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 460a48db2e6..5f672132a8a 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -5718,8 +5718,7 @@ vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info 
stmt_info,
       standard_iv_increment_position (loop, &incr_gsi, &insert_after);
 
       create_iv (aggr_ptr_init, PLUS_EXPR,
-                fold_convert (aggr_ptr_type, iv_step),
-                aggr_ptr, loop, &incr_gsi, insert_after,
+                iv_step, aggr_ptr, loop, &incr_gsi, insert_after,
                 &indx_before_incr, &indx_after_incr);
       incr = gsi_stmt (incr_gsi);
 
@@ -5747,7 +5746,7 @@ vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info 
stmt_info,
     {
       standard_iv_increment_position (containing_loop, &incr_gsi,
                                      &insert_after);
-      create_iv (aptr, PLUS_EXPR, fold_convert (aggr_ptr_type, DR_STEP (dr)),
+      create_iv (aptr, PLUS_EXPR, DR_STEP (dr),
                 aggr_ptr, containing_loop, &incr_gsi, insert_after,
                 &indx_before_incr, &indx_after_incr);
       incr = gsi_stmt (incr_gsi);
-- 
2.34.1

Reply via email to