This is a summary of discussions relative to the merge request created by
Samarth Tandale (sam-100) <[email protected]> titled
match.pd: Fold (a != 0) | (popcount(a) == n) and related patterns [PR112094]
since its creation.
Description: Fold (a != 0) | (popcount(a) == n) into (a != 0) | (n == 0), and
(a == 0) & (popcount(a) != n) into (a == 0) & (n != 0).
This follows from x == 0 => popcount(x) == 0: when a == 0 the
popcount comparison reduces to a comparison against zero, and when
a != 0 the outer OR/AND already determines the result.
PR tree-optimization/112094
```
gcc/ChangeLog:
* match.pd: Add fold for (a != 0) | (popcount(a) == n) and
(a == 0) & (popcount(a) != n).
gcc/testsuite/ChangeLog:
* gcc.dg/fold-popcount-12.c: New test.
* gcc.dg/fold-popcount-13.c: New test.
```
Signed-off-by: Samarth Tandale <[email protected]>
CC: [email protected]
The full and up to date discussion can be found at
https://forge.sourceware.org/gcc/gcc/pulls/233
The merge request has been closed without being merged directly on the forge
repository.
On 2026-09-28 07:35:31+00:00, Samarth Tandale (sam-100) wrote:
Pushed to GCC trunk by Jeff Law
commit-id: 56efa4a739786bb1c1c6dcdab0ad81cb1c55b970