This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/17151] New: x >> (y % WORDSIZE) not optimized
- From: "falk at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Aug 2004 13:30:30 -0000
- Subject: [Bug middle-end/17151] New: x >> (y % WORDSIZE) not optimized
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc 3.5-tree-ssa-lno 20040823 (merged 20040718)
gcc doesn't optimize shift count modulo word size, but curiously it does when
adding one more bit:
unsigned long f(unsigned long x, unsigned long y) { return x >> (y % 64); }
unsigned long g(unsigned long x, unsigned long y) { return x >> (y % 128); }
f:
and $17,63,$17
srl $16,$17,$0
ret
g:
srl $16,$17,$0
ret
It seems this is not a regression, already 2.95 behaved like this.
--
Summary: x >> (y % WORDSIZE) not optimized
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: minor
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: falk at debian dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: alphaev68-unknown-linux-gnu
GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17151