On Thu, Nov 27, 2025 at 02:50:11PM +0100, Richard Biener wrote:
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -4222,9 +4222,12 @@ vectorizable_simd_clone_call (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>    poly_uint64 vf = loop_vinfo ? LOOP_VINFO_VECT_FACTOR (loop_vinfo) : 1;
>    unsigned group_size = SLP_TREE_LANES (slp_node);
>    unsigned int badness = 0;
> +  unsigned int badness_inbranch = 0;
>    struct cgraph_node *bestn = NULL;
> +  struct cgraph_node *bestn_inbranch = NULL;
>    if (!cost_vec)
> -    bestn = cgraph_node::get (simd_clone_info[0]);
> +    bestn = ((loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
> +          ? data.clone_inbranch : data.clone);
>    else
>      for (struct cgraph_node *n = node->simd_clones; n != NULL;
>        n = n->simdclone->next_clone)
> @@ -4355,14 +4358,19 @@ vectorizable_simd_clone_call (vec_info *vinfo, 
> stmt_vec_info stmt_info,
>                       SIMD_CLONE_ARG_TYPE_MASK);
>           /* Penalize using a masked SIMD clone in a non-masked loop, that is
>              not in a branch, as we'd have to construct an all-true mask.  */
> -         if (!loop_vinfo || !LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
> -           this_badness += 64;
> +         this_badness += 64;

Shouldn't there be also this_badness and this_badness_inbranch, the latter
set to the former before the if containing this and so this affecting just
badness and not badness_inbranch?
>         }
>       if (bestn == NULL || this_badness < badness)
>         {
>           bestn = n;
>           badness = this_badness;
>         }
> +     if (n->simdclone->inbranch
> +         && (bestn_inbranch == NULL || this_badness < badness_inbranch))
> +       {
> +         bestn_inbranch = n;
> +         badness_inbranch = this_badness;
> +       }
>        }
>  

        Jakub

Reply via email to