JDK-6933327 : Use shifted addressing modes instead of shift instuctions
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-03-09
  • Updated: 2011-10-11
  • Resolved: 2010-08-25
Description
A DESCRIPTION OF THE REQUEST :
Java shift operator is mostly compiled to SAR instruction.
If shift factor is 8 or 16, often enhanced addressing modes could be used instead.

JUSTIFICATION :
- saves memory usage
- increases performance

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
MOV %bl, %ah / MOV %bl, xxx+1(yyy)

MOVSX %ebx, %ah / MOVSX %ebx, xxx+1(yyy)

MOVZX %ebx, %ah / MOVZX %ebx, xxx+1(yyy)

MOVSX %bx, xxx+2(yyy)

MOVSX %bx, xxx+2(yyy)

MOVHX %bx, xxx+2(yyy)

MOV %bl, xxx+1(yyy,zzz)

etc...

ACTUAL -
MOV %ebx, %eax / MOV %ebx, xxx(yyy)
SAR %ebx, $0x8

MOV %ebx, %eax / MOV %ebx, xxx(yyy)
SAR %ebx, $0x8

MOV %ebx, %eax / MOV %ebx, xxx(yyy)
SHR %ebx, $0x8

MOV %ebx, xxx(yyy)
SAR %ebx, $0x10

MOV %ebx, xxx(yyy)
SAR %ebx, $0x10

MOV %ebx, xxx(yyy)
SHR %ebx, $0x10

MOV %ebx, xxx(yyy,zzz)
SAR %ebx, $0x10

etc...


---------- BEGIN SOURCE ----------
short/char//int a;
byte b = a >> 8; / byte b = a >>> 8;

short/char//int a;
short/char//int b = a >> 8;

short/char//int a;
short/char//int b = a >>> 8;

int a;
short/char b = a >> 16; / short/char b = a >>> 16;

int a;
int b = a >> 16;

int a;
int b = a >>> 16;

short/char//int[] a;
byte b = a[] >> 8; / byte b = a[] >>> 8;

etc...
---------- END SOURCE ----------

Comments
EVALUATION Will not fix. Using addressing mode involves addess unit which may have negative effect if you have memory access instructions near this code.
11-10-2011