https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106888
--- Comment #5 from Roger Sayle <roger at nextmovesoftware dot com> --- Created attachment 54905 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54905&action=edit proposed patch This patch should fix this problem, by adding another pattern the machine description to also recognize zero_extend of clz/ctz/pcnt, matching the current pattern that only matches sign_extend. Clearly for SI operands, the result must always be 0..32, so sign extension and zero extension are equivalent, and the zero extension is perhaps (now) the preferred canonical form.