https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109011
--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 54590 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54590&action=edit gcc13-pr109011-2.patch Here is what I have right now, totally untested and will need further work so that the two pattern recognizers work together nicely (I think the one modified by the earlier patch will for ctz/ffs need to trigger first and allow ctz/ffs and be done even if for these they don't have direct optab but have ctz (for ffs), clz or popcount. And then let the new one rewrite it.