https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111913
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:452c4f32373feb6b2c1c1d91b5ec6fe7e7ce0000 commit r14-4888-g452c4f32373feb6b2c1c1d91b5ec6fe7e7ce0000 Author: Andrew Pinski <pins...@gmail.com> Date: Mon Oct 23 12:46:34 2023 -0700 match: Fix the `popcnt(a&b) + popcnt(a|b)` pattern for types [PR111913] So this pattern needs a little help on the gimple side of things to know what the type popcount should be. For most builtins, the type is the same as the input but popcount and others are not. And when using it with another outer expression, genmatch needs some slight help to know that the return type was type rather than the argument type. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/111913 gcc/ChangeLog: * match.pd (`popcount(X&Y) + popcount(X|Y)`): Add the resulting type for popcount. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/fold-popcount-1.c: New test. * gcc.dg/fold-popcount-8a.c: New test.