diff mbox series

[3/6] Query an appropriate offset vector type in vect_gather_scatter_fn_p

Message ID 20231213123253.EF03C38313B5@sourceware.org
State New
Headers show
Series Relax single-vector-size restriction | expand

Commit Message

Richard Biener Dec. 13, 2023, 12:31 p.m. UTC
The gather_load optab and friends require the offset vector mode to
have the same number of lanes as the data vector mode.  Restrict the
vector type query to that when searching for a proper offset type.

	* tree-vect-data-refs.cc (vect_gather_scatter_fn_p):
	Use get_related_vectype_for_scalar_type to get at the
	offset vector type.
---
 gcc/tree-vect-data-refs.cc | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 107dffe0a64..59e296e7976 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -3913,7 +3913,7 @@  vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
    *IFN_OUT and the vector type for the offset in *OFFSET_VECTYPE_OUT.  */
 
 bool
-vect_gather_scatter_fn_p (vec_info *vinfo, bool read_p, bool masked_p,
+vect_gather_scatter_fn_p (vec_info *, bool read_p, bool masked_p,
 			  tree vectype, tree memory_type, tree offset_type,
 			  int scale, internal_fn *ifn_out,
 			  tree *offset_vectype_out)
@@ -3948,13 +3948,18 @@  vect_gather_scatter_fn_p (vec_info *vinfo, bool read_p, bool masked_p,
 
   for (;;)
     {
-      tree offset_vectype = get_vectype_for_scalar_type (vinfo, offset_type);
-      if (!offset_vectype)
-	return false;
+      /* The optabs require the same number of elements in the offset
+	 vector as in the data vector.  */
+      tree offset_vectype
+	= get_related_vectype_for_scalar_type (TYPE_MODE (vectype), offset_type,
+					       TYPE_VECTOR_SUBPARTS (vectype));
 
       /* Test whether the target supports this combination.  */
-      if (internal_gather_scatter_fn_supported_p (ifn, vectype, memory_type,
-						  offset_vectype, scale))
+      if (!offset_vectype)
+	;
+      else if (internal_gather_scatter_fn_supported_p (ifn, vectype,
+						       memory_type,
+						       offset_vectype, scale))
 	{
 	  *ifn_out = ifn;
 	  *offset_vectype_out = offset_vectype;