On Wed, 17 Jun 2026, Hu, Lin1 wrote:

> Due to the patch modify middle-end.
> + Richard Biener and Richard Sandiford

LGTM, but please leave others the chance to chime in.  I think
the current code ensures op0 and op1 are a REG_P and
emit_cmp_and_jump_insns might not be able to force_reg if the
target requires?

> Thanks.
> 
> BRs,
> Lin
> 
> -----Original Message-----
> From: Hu, Lin1 <[email protected]> 
> Sent: Friday, June 5, 2026 2:26 PM
> To: [email protected]
> Cc: Liu, Hongtao <[email protected]>; [email protected]
> Subject: [PATCH 2/3] dojump: use simplify_expand_binop for vector boolean mask
> 
> When either op0 or op1 is a constant, expand_binop can emit an extra AND 
> during expansion. Use simplify_expand_binop here to avoid creating it in the 
> first place.
> 
> gcc/ChangeLog:
> 
>       * dojump.cc (do_compare_rtx_and_jump): Use simplify_expand_binop
>       instead of expand_binop.
> ---
>  gcc/dojump.cc | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/dojump.cc b/gcc/dojump.cc index 599a546b0de..1ed22116a27 
> 100644
> --- a/gcc/dojump.cc
> +++ b/gcc/dojump.cc
> @@ -1244,12 +1244,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum 
> rtx_code code, int unsignedp,
>         auto nunits = TYPE_VECTOR_SUBPARTS (TREE_TYPE (val)).to_constant ();
>         if (maybe_ne (GET_MODE_PRECISION (mode), nunits))
>           {
> -           op0 = expand_binop (mode, and_optab, op0,
> -                               GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
> -                               NULL_RTX, true, OPTAB_WIDEN);
> -           op1 = expand_binop (mode, and_optab, op1,
> -                               GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1),
> -                               NULL_RTX, true, OPTAB_WIDEN);
> +           rtx mask_imm = GEN_INT ((HOST_WIDE_INT_1U << nunits) - 1);
> +           op0 = simplify_expand_binop (mode, and_optab, op0, mask_imm,
> +                                        NULL_RTX, true, OPTAB_WIDEN);
> +           op1 = simplify_expand_binop (mode, and_optab, op1, mask_imm,
> +                                        NULL_RTX, true, OPTAB_WIDEN);
>           }
>       }
>  
> --
> 2.31.1
> 
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to