This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/66552] Missed optimization when shift amount is result of signed modulus
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Jun 2015 19:33:51 +0000
- Subject: [Bug c/66552] Missed optimization when shift amount is result of signed modulus
- Auto-submitted: auto-generated
- References: <bug-66552-4 at http dot gcc dot gnu dot org/bugzilla/>
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