https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106164

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>:

https://gcc.gnu.org/g:5e4a248b03f01f422b0dbc9e1464eb6c2f2bafc6

commit r14-3995-g5e4a248b03f01f422b0dbc9e1464eb6c2f2bafc6
Author: Andrew Pinski <apin...@marvell.com>
Date:   Wed Sep 13 16:50:33 2023 -0700

    MATCH: Support `(a != (CST+1)) & (a > CST)` optimizations

    Even though this is done via reassocation, match can support
    these with a simple change to detect that the difference is just
    one. This allows to optimize these earlier and even during phiopt
    for an example.

    This patch adds the following cases:
    (a != (CST+1)) & (a > CST) -> a > (CST+1)
    (a != (CST-1)) & (a < CST) -> a < (CST-1)
    (a == (CST-1)) | (a >= CST) -> a >= (CST-1)
    (a == (CST+1)) | (a <= CST) -> a <= (CST+1)

    Canonicalizations of comparisons causes this case to show up more.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

            PR tree-optimization/106164

    gcc/ChangeLog:

            * match.pd (`(X CMP1 CST1) AND/IOR (X CMP2 CST2)`):
            Expand to support constants that are off by one.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr21643.c: Update test now that match does
            the combing of the comparisons.
            * gcc.dg/tree-ssa/cmpbit-5.c: New test.
            * gcc.dg/tree-ssa/phi-opt-35.c: New test.

Reply via email to