On Wed, Nov 13, 2024 at 5:06 AM Jovan Vukic <jovan.vu...@rt-rk.com> wrote:
>
> The patch simplifies expressions (a - 1) & -a, (a - 1) | -a, and (a - 1) ^ -a
> to the constants 0, -1, and -1, respectively.
>
> Currently, GCC does not perform these simplifications.
>
> Bootstrapped and tested on x86-linux-gnu with no regressions.
>
> gcc/ChangeLog:
>
>         * match.pd: New pattern.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.dg/tree-ssa/bitops-11.c: New test.

Note the addition might be done in the opposite signed type but this
is a generic match issue and does not need to be solved with this
pattern just yet.

I think you should add an unsigned testcase.  Maybe even a vector
testcase. Also one with multiple statements rather than one
expression; to be able to test gimple rather than generic folding.
Adding this to simplify-rtx.cc might also be useful; though after the
match pattern it might be harder to invoke. BUT the addition of the
rtl level change should not block the match pattern to go in.


Thanks,
Andrew Pinski

>
>
> CONFIDENTIALITY: The contents of this e-mail are confidential and intended 
> only for the above addressee(s). If you are not the intended recipient, or 
> the person responsible for delivering it to the intended recipient, copying 
> or delivering it to anyone else or using it in any unauthorized manner is 
> prohibited and may be unlawful. If you receive this e-mail by mistake, please 
> notify the sender and the systems administrator at straym...@rt-rk.com 
> immediately.

Reply via email to