i386: Use SHR to compare with large power-of-two constants [PR94650]
authorUros Bizjak <ubizjak@gmail.com>
Mon, 4 May 2020 11:49:14 +0000 (13:49 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Mon, 4 May 2020 11:49:14 +0000 (13:49 +0200)
commit8ea03e9016cbca5a7ee2b4befa4d5c32467b0982
tree67d23af3275c8c5a39a516143abe17d843b0c210
parent6b5c7ee0df6b87780f2fd6f2c5759a04e6eed1fe
i386: Use SHR to compare with large power-of-two constants [PR94650]

Convert unsigned compares where

m >= LARGE_POWER_OF_TWO

and LARGE_POWER_OF_TWO represent an immediate where bit 33+ is set to use
a SHR instruction and compare the result to 0.  This avoids loading a
large immediate with MOVABS insn.

        movabsq $1099511627775, %rax
        cmpq    %rax, %rdi
        ja      .L5

gets converted to:

shrq $40, %rdi
jne .L5

PR target/94650
* config/i386/predicates.md (shr_comparison_operator): New predicate.
* config/i386/i386.md (compare->shr splitter): New splitters.

testsuite/ChangeLog:

PR target/94650
* gcc.targeti/i386/pr94650.c: New test.
gcc/ChangeLog
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr94650.c [new file with mode: 0644]