loop-niter: Recognize popcount idioms even with char, short and __int128 [PR95771]
authorJakub Jelinek <jakub@redhat.com>
Mon, 4 Jan 2021 13:36:06 +0000 (14:36 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 4 Jan 2021 13:36:06 +0000 (14:36 +0100)
commit24cd9afe617a39801d190418cf3fbab3bc3742a7
treebf580b45d997d0ebbe977b7a323cb5e64c945cb2
parent39bd65faee3bafe2dc067e5fedb5079896551a8a
loop-niter: Recognize popcount idioms even with char, short and __int128 [PR95771]

As the testcase shows, we punt unnecessarily on popcount loop idioms if
the type is smaller than int or larger than long long.
Smaller type than int can be handled by zero-extending the argument to
unsigned int, and types twice as long as long long by doing
__builtin_popcountll on both halves of the __int128.

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

PR tree-optimization/95771
* tree-ssa-loop-niter.c (number_of_iterations_popcount): Handle types
with precision smaller than int's precision and types with precision
twice as large as long long.  Formatting fixes.

* gcc.target/i386/pr95771.c: New test.
gcc/testsuite/gcc.target/i386/pr95771.c [new file with mode: 0644]
gcc/tree-ssa-loop-niter.c