Christophe, it looks like the zero-extend in the unsigned case is not needed on any target? Assuming the shifts are at least SImode, of course (I'm too lazy to check, sorry).It's also present when compiling: unsigned short swapu16(unsigned short x) { return __builtin_bswap16(x); } so it's not directly caused by my patch I think.
The RTL is (set (reg:HI) (bswap:HI (reg:HI))) which then gets extended for the SI (or DI) function return. Nothing to see here, it's a target problem. Your results look good. Segher
