]> gcc.gnu.org Git - gcc.git/commit
Improve double-word mod even on powerpc [PR97459]
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Dec 2020 15:25:06 +0000 (16:25 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 1 Dec 2020 15:25:06 +0000 (16:25 +0100)
commit855bb43f6d0bee5a74b5d3739456ca34b4609a50
tree8839e8e947d1c3ff16361bafe25a84050e414c53
parent404d0ca7820bbf258e2edfac423403ee31b48a7b
Improve double-word mod even on powerpc [PR97459]

I have noticed that while my (already committed, thanks for review)
patch works on x86, it doesn't work on powerpc*.  The problem is that
we don't have lshr double-word optab (neither TImode nor for -m32 DImode),
but as expander has code for double-word shift, that doesn't really matter.
As the implementation is prepared to punt whenever something can't be
expanded with OPTAB_DIRECT and in the end also punts if any library calls
would be emitted, the optab_handler checks were just to save compile time.

On the other side, for even divisors, we know that (1 << bit) % (2 * x)
for bit > 0 will never be equal to 1, because both dividend and divisor
are even and so remainder will be even too, so we can save some compile time
by adding an early exit.

The even divisors can be handled with the approach Thomas wrote about
(perhaps generalized into divisors equal to what expand_doubleword_mod
can handle times some power of two where we can handle power of two modulo
cheaply), but that would be done in a different function...
And we could use ctz to find the power of two...

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

PR rtl-optimization/97459
* optabs.c (expand_doubleword_mod): Punt early for even op1.
(expand_binop): Don't require lshr_optab double-word handler.
gcc/optabs.c
This page took 0.057764 seconds and 5 git commands to generate.