On 21 September 2012 12:56, Eric Botcazou <ebotca...@adacore.com> wrote: >> Here is a new patch, modifying tree-ssa-math-opts.c as you suggested. >> It's indeed simpler :-) >> >> Validated with qemu-arm on target arm-none-linux-gnueabi. > > I cannot formally approve, but this looks good to me. > > However, could you check that this is also an improvement for PowerPC, which > is the only other mainstream architecture with a bswaphi pattern AFAIK? > > -- > Eric Botcazou
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). 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? Christophe.