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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:49e8c14ef6f1f968602a04c8499a672182590e87

commit r11-6817-g49e8c14ef6f1f968602a04c8499a672182590e87
Author: Eugene Rozenfeld <ero...@microsoft.com>
Date:   Wed Dec 9 16:44:25 2020 -0800

    Optimize combination of comparisons to dec+compare

    This patch adds patterns for optimizing
    x < y || y == XXX_MIN to x <= y-1
    x >= y && y != XXX_MIN to x > y-1
    if y is an integer with TYPE_OVERFLOW_WRAPS.

    This fixes pr96674.

    Tested on x86_64-pc-linux-gnu.

    For this function

    bool f(unsigned a, unsigned b)
    {
        return (b == 0) | (a < b);
    }

    the code without the patch is

    test   esi,esi
    sete   al
    cmp    esi,edi
    seta   dl
    or     eax,edx
    ret

    the code with the patch is

    sub    esi,0x1
    cmp    esi,edi
    setae  al
    ret

            PR tree-optimization/96674
    gcc/
            * match.pd: New patterns: x < y || y == XXX_MIN --> x <= y - 1
            x >= y && y != XXX_MIN --> x > y - 1

    gcc/testsuite
            * gcc.dg/pr96674.c: New tests.

Reply via email to