> -----Original Message-----
> From: Alfie Richards <[email protected]>
> Sent: 21 August 2026 11:56
> To: Richard Biener <[email protected]>
> Cc: [email protected]; Alex Coplan <[email protected]>; Alice
> Carlotti <[email protected]>; [email protected]; Tamar
> Christina <[email protected]>; [email protected]; [email protected];
> [email protected]
> Subject: Re: [PATCH v2 05/13] vect: Add SLP_NODE argument to
> vect_get_loop_mask.
>
> On 21/08/2026 11:16, Richard Biener wrote:
> > On Fri, 7 Aug 2026, Alfie Richards wrote:
> >
> >> gcc/ChangeLog:
> >
> > Just looking at this in isolation - what's the reason to add this?
> Hi Richi,
>
> Thanks for taking a look.
>
> This is needed for getting the HSSR mask if the node is governed by a
> HSSR region.
>
> So needs to access slp_node->region->mask.
>
> >
> > tree
> > vect_get_loop_mask (loop_vec_info loop_vinfo,
> > gimple_stmt_iterator *gsi, vec_loop_masks *masks,
> > - unsigned int nvectors, tree vectype, unsigned int
> > index)
> > + unsigned int nvectors, tree vectype, unsigned int
> > index,
> > + slp_tree slp_node ATTRIBUTE_UNUSED)
> >
> > the interface stayed clear of stmt_vec_info vs. slp_node, if you
> > add slp_node isn't at least 'vectype' redundant? What of slp_node
> > do you need and can that be passed instead?
>
> I could pass the governing HSSR region instead, probably works nicely,
> null_ptr when we should use the loop mask instead.
>
> Will use that on the next version
FWIW, I've had a few times that because of the refactoring splits away from
the commit that makes use of them It makes it hard to figure out why.
Though I appreciate the splitting of the refactoring I'd suggest one of two
things
1. explain why you're doing it and refer to the commit that will use it.
2. split the commits differently. This and other refactoring are simple enough
that
I would have split them such that the implementation using ->region is in
the
same refactoring commit. I think this would give us better context and
makes
for easier review.
Thanks,
Tamar
>
> Thanks,
> Alfie
> >
> > Thanks,
> > Richard.
> >
> >> * tree-vect-loop.cc (vectorize_fold_left_reduction): Add slp_node
> >> argument.
> >> (vect_transform_reduction): Ditto.
> >> (vectorizable_live_operation_1): Ditto.
> >> (vect_get_loop_mask): Add SLP_NODE argument.
> >> * tree-vect-stmts.cc (vectorizable_call): Ditto.
> >> (vectorizable_simd_clone_call): Ditto.
> >> (vectorizable_operation): Ditto.
> >> (vectorizable_store): Ditto.
> >> (vectorizable_load): Ditto.
> >> (vectorizable_condition): Ditto.
> >> (vectorizable_early_exit): Ditto.
> >> * tree-vectorizer.h (vect_get_loop_mask): Add SLP_NODE argument.
> >> ---
> >> gcc/tree-vect-loop.cc | 12 +++++++-----
> >> gcc/tree-vect-stmts.cc | 39 +++++++++++++++++++++------------------
> >> gcc/tree-vectorizer.h | 2 +-
> >> 3 files changed, 29 insertions(+), 24 deletions(-)
> >>
> >> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> >> index 42843d17be8..b8eb58246a7 100644
> >> --- a/gcc/tree-vect-loop.cc
> >> +++ b/gcc/tree-vect-loop.cc
> >> @@ -6501,7 +6501,8 @@ vectorize_fold_left_reduction (loop_vec_info
> loop_vinfo,
> >> if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
> >> {
> >> tree loop_mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> - vec_num, vectype_in, i);
> >> + vec_num, vectype_in, i,
> >> + slp_node);
> >> if (is_cond_op)
> >> mask = prepare_vec_mask (loop_vinfo, TREE_TYPE (loop_mask),
> >> loop_mask, vec_opmask[i], gsi);
> >> @@ -8236,7 +8237,7 @@ vect_transform_reduction (loop_vec_info
> loop_vinfo,
> >>
> >> tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> vec_num, vectype_in,
> >> - mask_index++);
> >> + mask_index++, slp_node);
> >> gcall *call;
> >> if (code.is_internal_fn () && cond_fn_p)
> >> {
> >> @@ -8266,7 +8267,7 @@ vect_transform_reduction (loop_vec_info
> loop_vinfo,
> >> {
> >> tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> vec_num, vectype_in,
> >> - mask_index++);
> >> + mask_index++, slp_node);
> >> build_vect_cond_expr (code, vop, mask, gsi);
> >> }
> >>
> >> @@ -10157,7 +10158,7 @@ vectorizable_live_operation_1 (loop_vec_info
> loop_vinfo, basic_block exit_bb,
> >> gimple_stmt_iterator gsi = gsi_last (tem);
> >> tree mask = vect_get_loop_mask (loop_vinfo, &gsi,
> >> &LOOP_VINFO_MASKS (loop_vinfo),
> >> - 1, vectype, 0);
> >> + 1, vectype, 0, slp_node);
> >> tree scalar_res;
> >> gimple_seq_add_seq (&stmts, tem);
> >>
> >> @@ -10620,7 +10621,8 @@ vect_record_loop_mask (loop_vec_info
> loop_vinfo, vec_loop_masks *masks,
> >> tree
> >> vect_get_loop_mask (loop_vec_info loop_vinfo,
> >> gimple_stmt_iterator *gsi, vec_loop_masks *masks,
> >> - unsigned int nvectors, tree vectype, unsigned int index)
> >> + unsigned int nvectors, tree vectype, unsigned int index,
> >> + slp_tree slp_node ATTRIBUTE_UNUSED)
> >> {
> >> if (LOOP_VINFO_PARTIAL_VECTORS_STYLE (loop_vinfo)
> >> == vect_partial_vectors_while_ult)
> >> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> >> index 518ce00d585..7579c5c8cc6 100644
> >> --- a/gcc/tree-vect-stmts.cc
> >> +++ b/gcc/tree-vect-stmts.cc
> >> @@ -3809,7 +3809,8 @@ vectorizable_call (vec_info *vinfo,
> >> unsigned int vec_num = vec_oprnds0.length ();
> >> vargs[varg++] = vect_get_loop_mask (loop_vinfo, gsi,
> >> masks, vec_num,
> >> - vectype_out, i);
> >> + vectype_out, i,
> >> + slp_node);
> >> }
> >> else
> >> {
> >> @@ -3880,7 +3881,8 @@ vectorizable_call (vec_info *vinfo,
> >> {
> >> unsigned int vec_num = vec_oprnds0.length ();
> >> tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> - vec_num, vectype_out, i);
> >> + vec_num, vectype_out, i,
> >> + slp_node);
> >> vargs[mask_opno]
> >> = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask),
> mask,
> >> vargs[mask_opno], gsi);
> >> @@ -4689,7 +4691,7 @@ vectorizable_simd_clone_call (vec_info *vinfo,
> stmt_vec_info stmt_info,
> >> tree loop_mask
> >> = vect_get_loop_mask (loop_vinfo, gsi,
> >> loop_masks, ncopies_in,
> >> - vectype, j);
> >> + vectype, j, slp_node);
> >> vec_oprnd0
> >> = prepare_vec_mask (loop_vinfo,
> >> TREE_TYPE (loop_mask),
> >> @@ -4750,7 +4752,7 @@ vectorizable_simd_clone_call (vec_info *vinfo,
> stmt_vec_info stmt_info,
> >> tree loop_mask
> >> = vect_get_loop_mask (loop_vinfo, gsi,
> >> loop_masks, ncopies_in,
> >> - vectype, j);
> >> + vectype, j, slp_node);
> >> vec_oprnd0
> >> = prepare_vec_mask (loop_vinfo,
> >> TREE_TYPE (loop_mask),
> >> @@ -4900,7 +4902,8 @@ vectorizable_simd_clone_call (vec_info *vinfo,
> stmt_vec_info stmt_info,
> >> {
> >> vec_loop_masks *loop_masks = &LOOP_VINFO_MASKS
> (loop_vinfo);
> >> mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
> >> - ncopies * o, mask_vectype, m);
> >> + ncopies * o, mask_vectype, m,
> >> + slp_node);
> >> }
> >> else
> >> mask = vect_build_all_ones_mask (vinfo, stmt_info,
> >> @@ -7043,7 +7046,7 @@ vectorizable_operation (vec_info *vinfo,
> >> tree mask;
> >> if (masked_loop_p)
> >> mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i, slp_node);
> >> else
> >> /* Dummy mask. */
> >> mask = build_minus_one_cst (truth_type_for (vectype));
> >> @@ -7100,7 +7103,7 @@ vectorizable_operation (vec_info *vinfo,
> >> if (loop_vinfo->scalar_cond_masked_set.contains ({ op0, vec_num
> }))
> >> {
> >> mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i, slp_node);
> >>
> >> vop0 = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask),
> mask,
> >> vop0, gsi);
> >> @@ -7109,7 +7112,7 @@ vectorizable_operation (vec_info *vinfo,
> >> if (loop_vinfo->scalar_cond_masked_set.contains ({ op1, vec_num
> }))
> >> {
> >> mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i, slp_node);
> >>
> >> vop1 = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask),
> mask,
> >> vop1, gsi);
> >> @@ -8801,7 +8804,7 @@ vectorizable_store (vec_info *vinfo,
> >> tree bias = NULL;
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
> >> - ncopies, vectype, j);
> >> + ncopies, vectype, j, slp_node);
> >> if (vec_mask)
> >> final_mask = prepare_vec_mask (loop_vinfo, mask_vectype,
> final_mask,
> >> vec_mask, gsi);
> >> @@ -8944,7 +8947,7 @@ vectorizable_store (vec_info *vinfo,
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi,
> >> loop_masks, num_stmts,
> >> - vectype, j);
> >> + vectype, j, slp_node);
> >> if (vec_mask)
> >> final_mask = prepare_vec_mask (loop_vinfo, mask_vectype,
> >> final_mask, vec_mask, gsi);
> >> @@ -9361,7 +9364,7 @@ vectorizable_store (vec_info *vinfo,
> >> tree bias = NULL_TREE;
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i, slp_node);
> >> if (vec_mask)
> >> vec_mask = vec_masks[i];
> >> if (vec_mask)
> >> @@ -10778,7 +10781,7 @@ vectorizable_load (vec_info *vinfo,
> >> tree bias = NULL_TREE;
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
> >> - ncopies, vectype, j);
> >> + ncopies, vectype, j, slp_node);
> >> if (vec_mask)
> >> final_mask = prepare_vec_mask (loop_vinfo, mask_vectype,
> final_mask,
> >> vec_mask, gsi);
> >> @@ -10928,7 +10931,7 @@ vectorizable_load (vec_info *vinfo,
> >> vec_mask = vec_masks[i];
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi,
> loop_masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i,
> slp_node);
> >> if (vec_mask)
> >> final_mask = prepare_vec_mask (loop_vinfo, mask_vectype,
> >> final_mask, vec_mask, gsi);
> >> @@ -11402,7 +11405,7 @@ vectorizable_load (vec_info *vinfo,
> >> vec_mask = vec_masks[i];
> >> if (loop_masks)
> >> final_mask = vect_get_loop_mask (loop_vinfo, gsi, loop_masks,
> >> - vec_num, vectype, i);
> >> + vec_num, vectype, i, slp_node);
> >> if (vec_mask)
> >> final_mask = prepare_vec_mask (loop_vinfo, mask_vectype,
> >> final_mask, vec_mask, gsi);
> >> @@ -12542,7 +12545,7 @@ vectorizable_condition (vec_info *vinfo,
> >> {
> >> tree loop_mask
> >> = vect_get_loop_mask (loop_vinfo, gsi, masks, vec_num,
> >> - vectype, i);
> >> + vectype, i, slp_node);
> >> tree tmp2 = make_ssa_name (vec_cmp_type);
> >> gassign *g
> >> = gimple_build_assign (tmp2, BIT_AND_EXPR, vec_compare,
> >> @@ -13121,7 +13124,7 @@ vectorizable_early_exit (loop_vec_info
> loop_vinfo, stmt_vec_info stmt_info,
> >> {
> >> tree stmt_mask
> >> = vect_get_loop_mask (loop_vinfo, gsi, masks, vec_num,
> >> - vectype, i);
> >> + vectype, i, slp_node);
> >> stmt_mask
> >> = prepare_vec_mask (loop_vinfo, TREE_TYPE (stmt_mask),
> stmt_mask,
> >> stmts[i], &cond_gsi);
> >> @@ -13167,8 +13170,8 @@ vectorizable_early_exit (loop_vec_info
> loop_vinfo, stmt_vec_info stmt_info,
> >> new_temp = stmts[0];
> >> if (masked_loop_p)
> >> {
> >> - tree mask
> >> - = vect_get_loop_mask (loop_vinfo, gsi, masks, 1, vectype, 0);
> >> + tree mask = vect_get_loop_mask (loop_vinfo, gsi, masks, 1, vectype,
> 0,
> >> + slp_node);
> >> new_temp = prepare_vec_mask (loop_vinfo, TREE_TYPE (mask),
> mask,
> >> new_temp, &cond_gsi);
> >> }
> >> diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
> >> index 869b8497780..d15e04de369 100644
> >> --- a/gcc/tree-vectorizer.h
> >> +++ b/gcc/tree-vectorizer.h
> >> @@ -2701,7 +2701,7 @@ extern void vect_record_loop_mask
> (loop_vec_info, vec_loop_masks *,
> >> unsigned int, tree, tree);
> >> extern tree vect_get_loop_mask (loop_vec_info, gimple_stmt_iterator *,
> >> vec_loop_masks *,
> >> - unsigned int, tree, unsigned int);
> >> + unsigned int, tree, unsigned int, slp_tree);
> >> extern void vect_record_loop_len (loop_vec_info, vec_loop_lens *,
> unsigned int,
> >> tree, unsigned int);
> >> extern tree vect_get_loop_len (loop_vec_info, gimple_stmt_iterator *,
> >>
> >