tree-optimization/117709 - bogus offset for gather load

When diverting to VMAT_GATHER_SCATTER we fail to zero *poffset
which was previously set if a load was classified as
VMAT_CONTIGUOUS_REVERSE.  The following refactors
get_group_load_store_type a bit to avoid this but this all needs
some serious TLC.

	PR tree-optimization/117709
	* tree-vect-stmts.cc (get_group_load_store_type): Only
	set *poffset when we end up with VMAT_CONTIGUOUS_DOWN
	or VMAT_CONTIGUOUS_REVERSE.
This commit is contained in:
Richard Biener 2024-11-20 16:47:08 +01:00 committed by Richard Biener
parent 2383ed144b
commit f5bd88b5e8

View File

@ -2048,6 +2048,7 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info,
unsigned int group_size;
unsigned HOST_WIDE_INT gap;
bool single_element_p;
poly_int64 neg_ldst_offset = 0;
if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
{
first_stmt_info = DR_GROUP_FIRST_ELEMENT (stmt_info);
@ -2105,7 +2106,8 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info,
/* ??? The VMAT_CONTIGUOUS_REVERSE code generation is
only correct for single element "interleaving" SLP. */
*memory_access_type = get_negative_load_store_type
(vinfo, stmt_info, vectype, vls_type, 1, poffset);
(vinfo, stmt_info, vectype, vls_type, 1,
&neg_ldst_offset);
else
{
/* Try to use consecutive accesses of DR_GROUP_SIZE elements,
@ -2375,6 +2377,10 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info,
masked_p, gs_info, elsvals))
*memory_access_type = VMAT_GATHER_SCATTER;
if (*memory_access_type == VMAT_CONTIGUOUS_DOWN
|| *memory_access_type == VMAT_CONTIGUOUS_REVERSE)
*poffset = neg_ldst_offset;
if (*memory_access_type == VMAT_GATHER_SCATTER
|| *memory_access_type == VMAT_ELEMENTWISE
|| *memory_access_type == VMAT_STRIDED_SLP