https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69247
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 37321 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37321&action=edit gcc6-pr69247.patch Untested fix. At least if the fact that the bswaphi2 pattern sets some HImode register means it could clobber also the upper bits of that GPR register, this should hopefully work, even for the case when operands[0] == operands[1]. But, if it is split later than in split2, there is a risk that there will be a noop move left in the IL. So, alternative might be to have two different splitters, one for the can_create_pseudo_p () case with bswap, shift and move and another one for !can_create_pseudo_p () that would contain just bswap and shift. Or emit all the 2 or 3 (if needed) replacement insns in C code.