[3/6] Query an appropriate offset vector type in vect_gather_scatter_fn_p
Commit Message
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(-)
@@ -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;