i386: Optimize popcnt followed by zero/sign extension [PR91824]
authorJakub Jelinek <jakub@redhat.com>
Thu, 30 Jan 2020 08:39:05 +0000 (09:39 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 30 Jan 2020 08:39:05 +0000 (09:39 +0100)
commitb285bebe6ad1e9f6416f0eb6cb69edc44db7813c
tree28a294b50851fef478ce7d6a189f210086bc0686
parent2595f25cdaf4f16d04a1078a487b2ecc126cae29
i386: Optimize popcnt followed by zero/sign extension [PR91824]

Like any other instruction with 32-bit GPR destination operand in 64-bit
mode, popcntl also clears the upper 32 bits of the register (and other bits
too, it can return only 0 to 32 inclusive).

During combine, the zero or sign extensions of it show up as paradoxical
subreg of the popcount & 63, there 63 is the smallest power of two - 1 mask
that can represent all the 0 to 32 inclusive values.

2020-01-30  Jakub Jelinek  <jakub@redhat.com>

PR target/91824
* config/i386/i386.md (*popcountsi2_zext): New define_insn_and_split.
(*popcountsi2_zext_falsedep): New define_insn.

* gcc.target/i386/pr91824-1.c: New test.
gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr91824-1.c [new file with mode: 0644]