This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/17731] New: sub-optimal code generated for left shift


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]