> -----Original Message-----
> From: Robin Dapp <[email protected]>
> Sent: 08 December 2025 16:07
> To: gcc-patches <[email protected]>
> Cc: Robin Dapp <[email protected]>; Tamar Christina
> <[email protected]>
> Subject: [PATCH] optabs: Fix creation of length and bias operands.
> 
> Hi,
> 
> In the vec_cbranch_all/any optimization we prepare the length and bias
> operands slightly differently than expected.  This patch fixes it.
> 

I can't approve stuff in this area, but I think this is simple enough that you 
may
consider pushing it as obvious.  Or you need to CC Richi, but I think it
meets the bar.

That said I do have a question.  I was copying values from an existing LEN 
operation,
so are the modes on the types in GIMPLE not what we expand to with len?

i.e. for the bias is the type in GIMPLE made form something other than QImode?

Thanks,
Tamar

> Bootstrapped and regtested on x86, regtested on riscv64.
> 
> Regards
>  Robin
> 
> gcc/ChangeLog:
> 
>       * optabs.cc (emit_cmp_and_jump_insns): Fix len/bias operands.
> ---
>  gcc/optabs.cc | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/optabs.cc b/gcc/optabs.cc
> index 183ad910fcd..8dea94975c1 100644
> --- a/gcc/optabs.cc
> +++ b/gcc/optabs.cc
> @@ -4928,11 +4928,16 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum
> rtx_code comparison, rtx size,
>                 rtx len_bias_rtx = expand_normal (len_bias);
>                 tree lhs = gimple_get_lhs (def_stmt);
>                 auto mask_mode = TYPE_MODE (TREE_TYPE (lhs));
> +               /* ??? We could use something like internal_fn's
> +                  add_mask_else_and_len_args here.  Currently it
> +                  only supports a fixed, consecutive order of
> +                  mask and len, though.  */
>                 create_input_operand (&ops[0], CONSTM1_RTX
> (mask_mode),
>                                       mask_mode);
> -               create_input_operand (&ops[3], len_rtx, GET_MODE
> (len_rtx));
> -               create_input_operand (&ops[4], len_bias_rtx,
> -                                     GET_MODE (len_bias_rtx));
> +               create_convert_operand_from
> +                 (&ops[3], len_rtx, TYPE_MODE (TREE_TYPE (len_op)),
> +                  TYPE_UNSIGNED (TREE_TYPE (len_op)));
> +               create_input_operand (&ops[4], len_bias_rtx, QImode);
>               }
> 
>             int unsignedp2 = TYPE_UNSIGNED (TREE_TYPE (t_op0));
> --
> 2.51.1
> 

Reply via email to