i386: Use ADD to implement compares with negated operand [PR94913]
authorUros Bizjak <ubizjak@gmail.com>
Wed, 6 May 2020 15:33:51 +0000 (17:33 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 6 May 2020 15:33:51 +0000 (17:33 +0200)
commit7c2879301d3b027a1ba427a5d5c7557decb8a7ab
tree88de4ce841571a83a2dba3f013b5d79b2768a4f0
parent1266778548e20de82983b6446f3cb685068cfb1e
i386: Use ADD to implement compares with negated operand [PR94913]

Use carry flag from addition to implement GEU/LTU compares
with negated operand, so e.g.

~x < y

compiles to:

        addq    %rsi, %rdi
        setc    %al

instead of:

        notq    %rdi
        cmpq    %rsi, %rdi
        setb    %al

PR target/94913
* config/i386/predicates.md (add_comparison_operator): New predicate.
* config/i386/i386.md (compare->add splitter): New splitters.

testsuite/ChangeLog:

PR target/94913
* gcc.target/i386/pr94913-1.c: New test.
* gcc.target/i386/pr94913-2.c: Ditto.
gcc/ChangeLog
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr94913-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr94913-2.c [new file with mode: 0644]