public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/6] Query an appropriate offset vector type in vect_gather_scatter_fn_p
@ 2023-12-13 12:31 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-12-13 12:31 UTC (permalink / raw)
  To: gcc-patches

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 --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;
-- 
2.35.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-13 12:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 12:31 [PATCH 3/6] Query an appropriate offset vector type in vect_gather_scatter_fn_p Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).