https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66552
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Target|x86/generic |x86, powerpc64 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- On powerpc64, with -O2, GCC emits the following f: srawi 9,4,5 addze 9,9 slwi 9,9,5 subf 4,9,4 srw 3,3,4 rldicl 3,3,0,32 blr while Clang emits what looks like optimal code: f: rlwinm 4, 4, 0, 27, 31 srw 3, 3, 4 blr With the return expression rewritten as suggested (i.e., x >> (n & 31)), GCC still emits an extra instruction compare to Clang. I believe this aspect is tracked in bug 66217. rldicl 4,4,0,59 srw 3,3,4 rldicl 3,3,0,32 blr