https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105532
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am going to take care of this at least for GCC 13. There is another invalid use here too: /* Common POPCOUNT/PARITY simplifications. */ /* popcount(X&C1) is (X>>C2)&1 when C1 == 1<<C2. Same for parity(X&C1). */ (for pfun (POPCOUNT PARITY) (simplify (pfun @0) (with { wide_int nz = tree_nonzero_bits (@0); } (switch (if (nz == 1) (convert @0)) (if (wi::popcount (nz) == 1) (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); } (convert (rshift:utype (convert:utype @0) { build_int_cst (integer_type_node, wi::ctz (nz)); })))))))) Found while running the testsuite on x86_64. Another one: /* POPCOUNT simplifications. */ /* popcount(X) + popcount(Y) is popcount(X|Y) when X&Y must be zero. */ (simplify (plus (POPCOUNT:s @0) (POPCOUNT:s @1)) (if (wi::bit_and (tree_nonzero_bits (@0), tree_nonzero_bits (@1)) == 0) (POPCOUNT (bit_ior @0 @1)))) Those 3 are only ones I see in match.pd (the other uses of tree_nonzero_bits checks the type before the call).