]> git.ipfire.org Git - thirdparty/gcc.git/commit
rtlanal: Determine nonzero bits of popcount from operand [PR123501].
authorRobin Dapp <rdapp@oss.qualcomm.com>
Fri, 9 Jan 2026 12:25:40 +0000 (13:25 +0100)
committerRobin Dapp <rdapp@oss.qualcomm.com>
Tue, 13 Jan 2026 11:47:38 +0000 (12:47 +0100)
commit659f4d0e1e9a740fa8a18636bd7ec91cfefee26c
tree7a2165e8aa46fe789da3577b56a6321758a68a64
parent105fddf356d45bdbd159f8673f988a7bebe22f85
rtlanal: Determine nonzero bits of popcount from operand [PR123501].

The PR involves large mask vectors (e.g. V128BI) from which we take
the popcount.  Currently a (popcount:DI (V128BI)) is assumed to have
at most 8 set bits as we assume the popcount operand also has DImode.

This patch uses the operand mode for unary operations and thus
calculates a proper nonzero-bits mask.

We could do the same estimate for ctz and clz but they use nonzero in a
non-poly way and I didn't want to change more than necessary.  Therefore
the patch just returns -1 when we have a different operand mode for
ctz/clz.

PR rtl-optimization/123501
PR rtl-optimization/123444

gcc/ChangeLog:

* rtlanal.cc (nonzero_bits1): Use operand mode instead of
operation mode.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/reduc/pr123501.c: New test.
gcc/rtlanal.cc
gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/pr123501.c [new file with mode: 0644]