> -----Original Message-----
> From: Robin Dapp <[email protected]>
> Sent: 01 December 2025 21:25
> To: gcc-patches <[email protected]>
> Cc: Robin Dapp <[email protected]>; Tamar Christina
> <[email protected]>
> Subject: [PATCH] vect: Use loop len in vectorizable_scan_store.
>
> Hi,
>
> On riscv we ICE because we use SELECT_VL for a vectorizable_scan_store
> that calls vect_get_data_ptr_increment without a loop_lens argument.
>
> This patch just gets the loop_lens and passes them along. At the same time
> it removes the default nullptr argument. We should IMHO always pass
> loop_lens
> even if they end up unneeded. But we don't know that in advance.
>
> Bootstrapped and regtested on x86, power10, and aarch64. Regtested on
> riscv64.
>
OK.
Thanks,
Tamar
> Regards
> Robin
>
> gcc/ChangeLog:
>
> * tree-vect-stmts.cc (vectorizable_scan_store): Pass loop_lens
> to vect_get_data_ptr_increment.
> ---
> gcc/tree-vect-stmts.cc | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> index bf4c8c2cfd8..05a688bb6dc 100644
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -3275,7 +3275,7 @@ static tree
> vect_get_data_ptr_increment (vec_info *vinfo, gimple_stmt_iterator *gsi,
> dr_vec_info *dr_info, tree aggr_type,
> vect_memory_access_type memory_access_type,
> - vec_loop_lens *loop_lens = nullptr)
> + vec_loop_lens *loop_lens)
> {
> if (memory_access_type == VMAT_INVARIANT)
> return size_zero_node;
> @@ -7843,13 +7843,19 @@ vectorizable_scan_store (vec_info *vinfo,
> stmt_vec_info stmt_info,
> perms[i] = vect_gen_perm_mask_checked (vectype, indices);
> }
>
> + vec_loop_lens *loop_lens
> + = (loop_vinfo && LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo)
> + ? &LOOP_VINFO_LENS (loop_vinfo)
> + : NULL);
> +
> tree vec_oprnd1 = NULL_TREE;
> tree vec_oprnd2 = NULL_TREE;
> tree vec_oprnd3 = NULL_TREE;
> tree dataref_ptr = DR_BASE_ADDRESS (dr_info->dr);
> tree dataref_offset = build_int_cst (ref_type, 0);
> tree bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info,
> - vectype, VMAT_CONTIGUOUS);
> + vectype, VMAT_CONTIGUOUS,
> + loop_lens);
> tree ldataref_ptr = NULL_TREE;
> tree orig = NULL_TREE;
> if (STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) == 4 &&
> !inscan_var_store)
> --
> 2.51.1
>