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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <u...@gcc.gnu.org>:

https://gcc.gnu.org/g:9decd08b7b153a593a0b61e4f5373cb9574a1973

commit r11-45-g9decd08b7b153a593a0b61e4f5373cb9574a1973
Author: Uros Bizjak <ubiz...@gmail.com>
Date:   Mon May 4 18:53:30 2020 +0200

    i386: Use SBB more [PR94650]

    When returning 0 or -1, "SBB reg,reg" instruction that borrows carry
    flag can be used.  Carry flag can be generated by converting compare
    with zero to a LTU compare with one, so e.g.

            return -(x == 0)

    generates:

            cmpq    $1, %rdi
            sbbq    %rax, %rax

    instead of:

            xorl    %eax, %eax
            testq   %rdi, %rdi
            sete    %al
            negq    %rax

    A similar conversion can be used for

            return -(x != 0)

    where NEG insn can be used instead of compare.  According to x86 ISA,
    NEG insn sets carry flag when the source operand is != 0, resulting in:

            negq    %rdi
            sbbq    %rax, %rax

    The conversion avoids partial register stall with SETcc instructions.

            PR target/94795
            * config/i386/i386.md (*neg<mode>_ccc): New insn pattern.
            (EQ compare->LTU compare splitter): New splitter.
            (NE compare->NEG splitter): Ditto.

    testsuite/ChangeLog:

            PR target/94795
            * gcc.target/i386/pr94795-1.c: New test.
            * gcc.target/i386/pr94795-2.c: New test.

Reply via email to