On Tue, Dec 16, 2025 at 1:36 PM Robin Dapp <[email protected]> wrote:
>
> Hi,
>
> In the process of refactoring the gather/scatter rework this likely got
> lost.  In the "third pass" that we look for a configuration with a
> smaller scale and a larger offset type with the same signedness.
> We want to be able to multiply the offset by the new
> scale but not change the offset sign.  What we actually checked is
> whether a converted offset type was supported without setting
> *supported_offset_vectype.
>
> This patch removes the check for the offset type change and replaces it
> with a TYPE_SIGN match.
>
> Bootstrapped and regtested on x86 and power10.  Regtested on riscv64 and
> aarch64.

OK.

> Regards
>  Robin
>
>         PR tree-optimization/123118
>
> gcc/ChangeLog:
>
>         * tree-vect-data-refs.cc (vect_gather_scatter_fn_p): Check that
>         the type sign is equal.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.target/riscv/rvv/autovec/pr123118.C: New test.
> ---
>  .../g++.target/riscv/rvv/autovec/pr123118.C   | 19 +++++++++++++++++++
>  gcc/tree-vect-data-refs.cc                    | 10 +++-------
>  2 files changed, 22 insertions(+), 7 deletions(-)
>  create mode 100644 gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C
>
> diff --git a/gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C 
> b/gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C
> new file mode 100644
> index 00000000000..8cef5a7fe91
> --- /dev/null
> +++ b/gcc/testsuite/g++.target/riscv/rvv/autovec/pr123118.C
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -march=rv64gcv -mabi=lp64d" } */
> +
> +long long a;
> +short c, d;
> +extern int e[][1][1][1];
> +extern bool f[][1][4][2];
> +#include <vector>
> +
> +void
> +g ()
> +{
> +  for (bool b;;)
> +    for (signed char h (c); h < 4; h += -4487 - 119)
> +      {
> +       e[b][b][b][b] = std::max (std::min ((long long) 3, a), (long long) d);
> +       f[0][0][h][1] = h;
> +      }
> +}
> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
> index b35ba05fd08..f12e1f6af5b 100644
> --- a/gcc/tree-vect-data-refs.cc
> +++ b/gcc/tree-vect-data-refs.cc
> @@ -4709,13 +4709,9 @@ vect_gather_scatter_fn_p (vec_info *vinfo, bool 
> read_p, bool masked_p,
>        unsigned int precision
>         = TYPE_PRECISION (TREE_TYPE (configs[i].offset_vectype));
>        if (configs[i].scale < scale
> -         && precision >= needed_precision
> -         && (supportable_convert_operation (CONVERT_EXPR,
> -                                           configs[i].offset_vectype,
> -                                           offset_vectype, &tmp)
> -             || (needed_precision == offset_precision
> -                 && tree_nop_conversion_p (configs[i].offset_vectype,
> -                                           offset_vectype))))
> +         && TYPE_SIGN (configs[i].offset_vectype)
> +            == TYPE_SIGN (offset_vectype)
> +         && precision >= needed_precision)
>         {
>           *ifn_out = configs[i].ifn;
>           *offset_vectype_out = configs[i].offset_vectype;
> --
> 2.51.1
>

Reply via email to