given something like: long long foo(long long X, unsigned int Y) { return X << Y; } or long long foo(long long X, unsigned int Y) { return X >> Y; }
We currently generate a libcall to do the shift in 32 bit ppc. On the contrary, XLC will *always* expand these shifts to an instruction sequence (LLVM now does the same as of a few days ago), rather than a library call. The first will generate with xlc -O3 -qarch=ppc970 .foo: rlwinm r0,r5,25,0,6 subfic r6,r5,32 slw r3,r3,r5 addi r7,r5,-32 srw r6,r4,r6 xoris r0,r0,0x8000 slw r7,r4,r7 slw r4,r4,r5 or r5,r6,r7 srawi r0,r0,31 or r3,r3,r5 and r4,r0,r4 and r3,r0,r3 and the second: .foo: subfic r0,r5,32 addi r8,r5,-32 rlwinm r6,r5,26,0,0 rlwinm r7,r5,25,0,6 srw r8,r3,r8 slw r9,r3,r0 xoris r7,r7,0x8000 srw r0,r4,r5 and r4,r3,r6 or r9,r9,r8 or r0,r0,r9 srawi r6,r7,31 srawi r8,r3,31 rlwinm r7,r5,0,27,31 sraw r4,r4,r7 sraw r3,r3,r5 or r0,r0,r4 andc r5,r8,r6 and r3,r6,r3 and r0,r6,r0 or r4,r5,r0 or r3,r5,r3 (O5 will give slightly better code for both, but let's start somewhere :P) -- Summary: 64 bit shift by non-constant implemented as libcall on PPC32 Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dberlin at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-linux GCC host triplet: powerpc-linux GCC target triplet: powerpc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20781