This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug java/17731] New: sub-optimal code generated for left shift
- From: "tromey at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 29 Sep 2004 17:58:04 -0000
- Subject: [Bug java/17731] New: sub-optimal code generated for left shift
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider this java method:
public int shift (int x, int y)
{
return x << y;
}
On x86, with -O3, this becomes:
_ZN1t5shiftEii:
.LFB2:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
movl 16(%ebp), %ecx
movl 12(%ebp), %eax
popl %ebp
andl $31, %ecx
sall %cl, %eax
ret
However, on x86 (starting with 80286), the shift count is masked
to 5 bits by sall, so the "andl" instruction is redundant.
I haven't looked to see exactly where this buglet might lie.
--
Summary: sub-optimal code generated for left shift
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tromey at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17731