]> git.ipfire.org Git - thirdparty/gcc.git/commit
match.pd: Simplify popcount/parity of bswap/rotate.
authorRoger Sayle <roger@nextmovesoftware.com>
Thu, 11 May 2023 07:10:04 +0000 (08:10 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Thu, 11 May 2023 07:10:04 +0000 (08:10 +0100)
commitc0dd80e4c4c332ed8c65dd96528cc2dc9e9e5ef7
treed38ac71917fbbd86b13e0f51feb49d9054e75e22
parent003f388cddbbd3c8ff936f98355a90acda619030
match.pd: Simplify popcount/parity of bswap/rotate.

This is the latest iteration of my patch from August 2020
https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552391.html
incorperating feedback and suggestions from reviewers.

This patch to match.pd optimizes away bit permutation operations,
specifically bswap and rotate, in calls to popcount and parity.

2023-05-11  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* match.pd <popcount optimizations>: Simplify popcount(bswap(x))
as popcount(x).  Simplify popcount(rotate(x,y)) as popcount(x).
<parity optimizations>:  Simplify parity(bswap(x)) as parity(x).
Simplify parity(rotate(x,y)) as parity(x).

gcc/testsuite/ChangeLog
* gcc.dg/fold-parity-6.c: New test.
* gcc.dg/fold-parity-7.c: Likewise.
* gcc.dg/fold-popcount-6.c: Likewise.
* gcc.dg/fold-popcount-7.c: Likewise.
gcc/match.pd
gcc/testsuite/gcc.dg/fold-parity-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/fold-parity-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/fold-popcount-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/fold-popcount-7.c [new file with mode: 0644]