https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63259
--- Comment #17 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to thopre01 from comment #16) > > Did we? All I can find is you and Andreas mentionning that it should work > because it will be sign extended to int when doing the bitwise AND with > 0xFF00. > > What did I miss? Ah sorry ... me bad. I haven't tried increasing the 'level' with the bswaphi expander pattern in place. Will do that later. > > > If you have a bswap instruction it seems better to define a pattern for > > > that > > > which the expander will use. That's the job of the bswap pass to detect a > > > bswap, it shouldn't be done by combine. > > > > The combine parts I was talking about are to eliminate the anding and oring > > of higher 16 bits when a 16 bit byte swap is done on a 32 bit value. > > I'm surprised that it's not the semantic of a bswaphi. As far as I know... bswaphi's inputs/output modes are HImode and it operates on the whole reg, not on a subreg. If applied to a SImode subreg the other bits need to be saved/restored, which is what happens wiit the anding/oring.