https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106888
--- Comment #9 from Vineet Gupta <vineetg at gcc dot gnu.org> --- (In reply to Jeffrey A. Law from comment #6) > Comment on attachment 54905 [details] > proposed patch > > So that's a subset of what we've done. We initially thought that was going > to be enough to solve this class of problems. But it's actually deeper > than just having a zero_extension variant of this pattern. Yeah it seems adding a new define_insn with zero_extend is not enough (nor is the more elegant any_extend to existing "*<bitmanip_optab>disi2") Thing is at expand time, we have gimple CTZ expand to ctz+sign_extend, so adding zero_extend won't really help ? (insn 6 3 7 2 (set (reg:SI 74) (ctz:SI (subreg/s/u:SI (reg/v:DI 73 [ x ]) 0))) "pr90838-red.c":11:15 -1 (nil)) (insn 7 6 8 2 (set (reg:DI 72 [ <retval> ]) (sign_extend:DI (reg:SI 74))) "pr90838-red.c":11:15 -1 (nil)) > I'll officially submit the zero_extension pattern and the match.pd bits. > The other pattern we wrote is fugly and I'd like to look at it one more time. But that other pattern is needed for combine to fuse them together.