[Bug c/66552] Missed optimization when shift amount is result of signed modulus
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 17 19:33:00 GMT 2015
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
More information about the Gcc-bugs
mailing list