> I have not yet been able to build an environment to run the testsuite > with qemu-ppc (not sure about the best target & dejagnu board > selection).
No problem, that wasn't really a requirement. > However, when compiling a sample test > short myswaps16(short x) { > return (x << 8) | (x >> 8); > } > unsigned short myswapu16(unsigned short x) { > return (x << 8) | (x >> 8); > } > > The generated code is now: > myswaps16: > rlwinm 10,3,8,16,23 > rlwinm 9,3,24,24,31 > or 9,9,10 > extsh 3,9 > blr > > myswapu16: > rlwinm 10,3,8,16,23 > rlwinm 9,3,24,24,31 > or 9,9,10 > rlwinm 3,9,0,0xffff > blr > > While it was (without my patch): > > myswaps16: > slwi 9,3,8 > srawi 3,3,8 > or 3,9,3 > extsh 3,3 > blr > > myswapu16: > srwi 9,3,8 > rlwinm 3,3,8,16,23 > or 3,3,9 > blr > > I don't know PowerPC, but I am not sure it's an improvement. Is it? That indeed doesn't look obvious, especially in the unsigned case. The PowerPC back-end has a splitter for bswap:HI which generates no less than 3 instructions, so I presume we're seeing its effects here. I've CCed the other interested parties. David, Michael, Segher, any comments about or insights into the results reported by Christophe for PowerPC? -- Eric Botcazou