Re: [PATCH 1/2] match: Combine four fors into one for.

Andrea Pinski <[email protected]> Sat, 1 Aug 2026 22:09:00 -0700
Newsgroups gmane.comp.gcc.patches
Message-ID <CALvbMcBHhUhm5V1HwB9EZpLkRih0Ez8Vwf2yyum79wmb2a7zzg@mail.gmail.com>
On Sat, Aug 1, 2026 at 7:31 AM Kael Andrew Franco <[email protected]> wrote:
>
> From 106550f07a688b7f748313030ccd91c4ccf682b7 Mon Sep 17 00:00:00 2001
> From: Kael Andrew Alonzo Franco <[email protected]>
> Date: Fri, 31 Jul 2026 20:37:40 -0400
> Subject: [PATCH 1/2] match: Combine four fors into one for.
>
> This reduce genmatch's outputted C++ code.
>
> Bootstrapped and tested on x86_64-pc-linux-gnu.
>
> PR tree-optimization/117760
> PR tree-optimization/125442
>
> gcc/ChangeLog:
>
> * match.pd: Combine four fors into one for.

Ok, thanks again for these cleanups.


>
> Signed-off-by: Kael Andrew Franco <[email protected]>
> ---
>  gcc/match.pd | 29 +++++++++++------------------
>  1 file changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index b757aaf6f69..aa7cada1b64 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -6883,30 +6883,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>     (a != b) | ((a|b) != 0) -> ((a|b) != 0)
>
>     (a != b) & ((a|b) == 0) -> false
> -   (a == b) | ((a|b) != 0) -> true  */
> +   (a == b) | ((a|b) != 0) -> true
> +
> +   (a == 0) | ((a | b) == 0) -> (a == 0)
> +   (a != 0) & ((a | b) != 0) -> (a != 0)  */
>  (for bitop (bit_and bit_ior)
>       neeq  (ne      eq)
> +     eqne  (eq      ne)
>   (simplify
>    (bitop:c (neeq @0 @1) (neeq (bit_ior @0 @1) integer_zerop))
> -  (neeq @0 @1)))
> -(for bitop (bit_and bit_ior)
> -     neeq  (eq      ne)
> +  (neeq @0 @1))
>   (simplify
> -  (bitop:c (neeq @0 @1) (neeq (bit_ior@2 @0 @1) integer_zerop@3))
> -  (neeq @2 @3)))
> -(for bitop (bit_and bit_ior)
> -     neeql (ne      eq)
> -     neeqr (eq      ne)
> +  (bitop:c (eqne @0 @1) (eqne (bit_ior@2 @0 @1) integer_zerop@3))
> +  (neeq @2 @3))
> + (simplify
> +  (bitop (neeq @0 @1) (eqne (bit_ior @0 @1) integer_zerop))
> +  { constant_boolean_node (bitop == BIT_IOR_EXPR, type); })
>   (simplify
> -  (bitop (neeql @0 @1) (neeqr (bit_ior @0 @1) integer_zerop))
> -  { constant_boolean_node (bitop == BIT_IOR_EXPR, type); }))
> -
> -/* (a == 0) | ((a | b) == 0) -> (a == 0) -- PR125442
> -   (a != 0) & ((a | b) != 0) -> (a != 0) -- PR125442 */
> -
> -(for bitop (bit_and bit_ior)
> -     neeq  (ne      eq)
> -(simplify
>    (bitop:c (neeq@2 @0 integer_zerop) (neeq (bit_ior:c @0 @1) integer_zerop))
>    @2))
>  #endif
> --
> 2.55.0
>
>