> -----Original Message-----
> From: Takayuki 'January June' Suwa <[email protected]>
> Sent: 16 May 2026 15:04
> To: [email protected]
> Subject: [PATCH] match.pd: (x & ~m) + (y & m) -> ((x ^ y) & m) ^ x, as
> well as (x & ~m) | (y & m)
> 
> External email: Use caution opening links or attachments
> 
> 
> It is obvious that the results of logical-OR and addition of two
> bitwise disjoint terms are equal.
> 
> gcc/ChangeLog:
> 
>         * match.pd ((x & ~m) | (y & m)): Change `bit_ior` to `op`, and
> then
>         modify it so that `op` expands to both `bit_ior` and `plus`.
Hi,
The patch needs a test-case for the newly added pattern (x & ~m) + (y & m) -> 
((x ^ y) & m) ^ x.
Also, could you please mention on which target the patch was 
bootstrapped+reg-tested ?

Thanks,
Prathamesh
> ---
>   gcc/match.pd | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/match.pd b/gcc/match.pd index
> 4ed058f6e18..d45dd9f8cf6 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -2704,10 +2704,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>         && TYPE_PRECISION (TREE_TYPE (@0)) == 1)
>     (convert (bit_xor @0 @1))))
> 
> -/* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */ -(simplify
> - (bit_ior:c (bit_and:cs @0 (bit_not @2)) (bit_and:cs @1 @2))
> - (bit_xor (bit_and (bit_xor @0 @1) @2) @0))
> +/* (x & ~m) |+ (y & m) -> ((x ^ y) & m) ^ x */ (for op (bit_ior plus)
> +(simplify
> +  (op:c (bit_and:cs @0 (bit_not @2)) (bit_and:cs @1 @2))
> +  (bit_xor (bit_and (bit_xor @0 @1) @2) @0)))
> 
>   /* Fold A - (A & B) into ~B & A.  */
>   (simplify
> --
> 2.39.5

Reply via email to