https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91202
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Perhaps we could define patterns for combine like: (set (match_operand:SI 0 "register_operand" "=q") (ashiftrt:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "q")) (match_operand:QI 2 "nonmemory_operand" "cI"))) (clobber (reg:CC 17 flags)) etc. and split them before reload into an insn that does that with a subreg:QI followed by zero extension (or sign extension in certain cases) and then hope before reload the zero extension will be cancelled with the following subreg use (I guess we can't look at immediate uses during splitting). The disadvantage would be that this would match even if we aren't using a subreg at the end, so would match even the case of: unsigned int foo (unsigned char a, unsigned char b) { return a >> b; } and would change the movzbl %dil, %edi; shrq %cl, %edi into shrq %cl, %dil; movzbl %dil, %edi. Dunno if that is acceptable.