Unify offset and byte_offset for vect_create_addr_base_for_vector_ref

Message ID p55q12qq-npq0-59p5-9265-7n5676q47538@fhfr.qr
State Committed
Commit 6adfdff68b1fef146b97c39d4b9d8db59d498837
Headers
Series Unify offset and byte_offset for vect_create_addr_base_for_vector_ref |

Commit Message

Richard Biener Oct. 26, 2021, 11:28 a.m. UTC
  Now that both are measured in bytes we can unify the two parameters.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-10-26  Richard Biener  <rguenther@suse.de>

	* tree-vectorizer.h (vect_create_addr_base_for_vector_ref):
	Remove byte_offset parameter.
	(vect_create_data_ref_ptr): Likewise.
	* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
	Likewise.
	(vect_create_data_ref_ptr): Likewise.
	* tree-vect-stmts.c (vectorizable_store): Adjust.
	(vectorizable_load): Likewise.
---
 gcc/tree-vect-data-refs.c | 21 ++++-----------------
 gcc/tree-vect-stmts.c     | 18 +++++++++---------
 gcc/tree-vectorizer.h     |  4 ++--
 3 files changed, 15 insertions(+), 28 deletions(-)
  

Patch

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index cda89ef9725..2ea8e983fe6 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4772,8 +4772,6 @@  vect_duplicate_ssa_name_ptr_info (tree name, dr_vec_info *dr_info)
 	    is as follows:
 	    if LOOP=i_loop:	&in		(relative to i_loop)
 	    if LOOP=j_loop: 	&in+i*2B	(relative to j_loop)
-   BYTE_OFFSET: Optional, defaulted to NULL.  If supplied, it is added to the
-	    initial address.  Both OFFSET and BYTE_OFFSET are measured in bytes.
 
    Output:
    1. Return an SSA_NAME whose value is the address of the memory location of
@@ -4786,8 +4784,7 @@  vect_duplicate_ssa_name_ptr_info (tree name, dr_vec_info *dr_info)
 tree
 vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info,
 				      gimple_seq *new_stmt_list,
-				      tree offset,
-				      tree byte_offset)
+				      tree offset)
 {
   dr_vec_info *dr_info = STMT_VINFO_DR_INFO (stmt_info);
   struct data_reference *dr = dr_info->dr;
@@ -4823,12 +4820,6 @@  vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info,
       base_offset = fold_build2 (PLUS_EXPR, sizetype,
 				 base_offset, offset);
     }
-  if (byte_offset)
-    {
-      byte_offset = fold_convert (sizetype, byte_offset);
-      base_offset = fold_build2 (PLUS_EXPR, sizetype,
-				 base_offset, byte_offset);
-    }
 
   /* base + base_offset */
   if (loop_vinfo)
@@ -4882,10 +4873,6 @@  vect_create_addr_base_for_vector_ref (vec_info *vinfo, stmt_vec_info stmt_info,
    5. BSI: location where the new stmts are to be placed if there is no loop
    6. ONLY_INIT: indicate if ap is to be updated in the loop, or remain
         pointing to the initial address.
-   7. BYTE_OFFSET (optional, defaults to NULL): a byte offset to be added
-	to the initial address accessed by the data-ref in STMT_INFO.  This is
-	similar to OFFSET, but OFFSET is counted in elements, while BYTE_OFFSET
-	in bytes.
    8. IV_STEP (optional, defaults to NULL): the amount that should be added
 	to the IV during each iteration of the loop.  NULL says to move
 	by one copy of AGGR_TYPE up or down, depending on the step of the
@@ -4920,7 +4907,7 @@  vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info stmt_info,
 			  tree aggr_type, class loop *at_loop, tree offset,
 			  tree *initial_address, gimple_stmt_iterator *gsi,
 			  gimple **ptr_incr, bool only_init,
-			  tree byte_offset, tree iv_step)
+			  tree iv_step)
 {
   const char *base_name;
   loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
@@ -5048,11 +5035,11 @@  vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info stmt_info,
   /* (2) Calculate the initial address of the aggregate-pointer, and set
      the aggregate-pointer to point to it before the loop.  */
 
-  /* Create: (&(base[init_val]+offset+byte_offset) in the loop preheader.  */
+  /* Create: (&(base[init_val]+offset) in the loop preheader.  */
 
   new_temp = vect_create_addr_base_for_vector_ref (vinfo,
 						   stmt_info, &new_stmt_list,
-						   offset, byte_offset);
+						   offset);
   if (new_stmt_list)
     {
       if (pe)
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 3cd338a73eb..bf07e7a9495 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -8110,7 +8110,7 @@  vectorizable_store (vec_info *vinfo,
 	      = vect_create_data_ref_ptr (vinfo, first_stmt_info, aggr_type,
 					  simd_lane_access_p ? loop : NULL,
 					  offset, &dummy, gsi, &ptr_incr,
-					  simd_lane_access_p, NULL_TREE, bump);
+					  simd_lane_access_p, bump);
 	}
       else
 	{
@@ -8518,7 +8518,6 @@  vectorizable_load (vec_info *vinfo,
   unsigned int group_size;
   poly_uint64 group_gap_adj;
   tree msq = NULL_TREE, lsq;
-  tree byte_offset = NULL_TREE;
   tree realignment_token = NULL_TREE;
   gphi *phi = NULL;
   vec<tree> dr_chain = vNULL;
@@ -9290,6 +9289,7 @@  vectorizable_load (vec_info *vinfo,
   bool diff_first_stmt_info
     = first_stmt_info_for_drptr && first_stmt_info != first_stmt_info_for_drptr;
 
+  tree offset = NULL_TREE;
   if ((alignment_support_scheme == dr_explicit_realign_optimized
        || alignment_support_scheme == dr_explicit_realign)
       && !compute_in_loop)
@@ -9306,17 +9306,18 @@  vectorizable_load (vec_info *vinfo,
       if (alignment_support_scheme == dr_explicit_realign_optimized)
 	{
 	  phi = as_a <gphi *> (SSA_NAME_DEF_STMT (msq));
-	  byte_offset = size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (vectype),
-				    size_one_node);
+	  offset = size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (vectype),
+			       size_one_node);
 	  gcc_assert (!first_stmt_info_for_drptr);
 	}
     }
   else
     at_loop = loop;
 
-  tree offset = NULL_TREE;
   if (!known_eq (poffset, 0))
-    offset = size_int (poffset);
+    offset = (offset
+	      ? size_binop (PLUS_EXPR, offset, size_int (poffset))
+	      : size_int (poffset));
 
   tree bump;
   tree vec_offset = NULL_TREE;
@@ -9374,7 +9375,7 @@  vectorizable_load (vec_info *vinfo,
 		= vect_create_data_ref_ptr (vinfo, first_stmt_info_for_drptr,
 					    aggr_type, at_loop, offset, &dummy,
 					    gsi, &ptr_incr, simd_lane_access_p,
-					    byte_offset, bump);
+					    bump);
 	      /* Adjust the pointer by the difference to first_stmt.  */
 	      data_reference_p ptrdr
 		= STMT_VINFO_DATA_REF (first_stmt_info_for_drptr);
@@ -9406,8 +9407,7 @@  vectorizable_load (vec_info *vinfo,
 	      = vect_create_data_ref_ptr (vinfo, first_stmt_info, aggr_type,
 					  at_loop,
 					  offset, &dummy, gsi, &ptr_incr,
-					  simd_lane_access_p,
-					  byte_offset, bump);
+					  simd_lane_access_p, bump);
 	  if (mask)
 	    vec_mask = vec_masks[0];
 	}
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 52cdfbfae02..73347ce1f4e 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2003,7 +2003,7 @@  extern tree vect_create_data_ref_ptr (vec_info *,
 				      stmt_vec_info, tree, class loop *, tree,
 				      tree *, gimple_stmt_iterator *,
 				      gimple **, bool,
-				      tree = NULL_TREE, tree = NULL_TREE);
+				      tree = NULL_TREE);
 extern tree bump_vector_ptr (vec_info *, tree, gimple *, gimple_stmt_iterator *,
 			     stmt_vec_info, tree);
 extern void vect_copy_ref_info (tree, tree);
@@ -2028,7 +2028,7 @@  extern tree vect_get_new_ssa_name (tree, enum vect_var_kind,
 				   const char * = NULL);
 extern tree vect_create_addr_base_for_vector_ref (vec_info *,
 						  stmt_vec_info, gimple_seq *,
-						  tree, tree = NULL_TREE);
+						  tree);
 
 /* In tree-vect-loop.c.  */
 extern widest_int vect_iv_limit_for_partial_vectors (loop_vec_info loop_vinfo);