JDK-6797305 : Add LoadUB and LoadUI opcode class
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs15,5.0,5.0u4,6,7
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,solaris_9,solaris_10,windows_xp generic,solaris_9,solaris_10,windows_xp
  • CPU: generic,x86,sparc
  • Submitted: 2009-01-23
  • Updated: 2013-11-01
  • Resolved: 2009-03-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u18Fixed 7Fixed hs15Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Add a LoadUB (unsigned byte) and LoadUI (unsigned int) opcode class so we have these load optimizations in the first place and do not need to handle them in the matcher.

These classes will handle code like, e.g.:

bytearray[i] & 0xFF
intarray[i] & 0xFFFFFFFF

EVALUATION @brackeen: Well the only thing I can think of (for x86) is to use partial register moves (using MOVZX instructions instead of SHR-AND sequences), e.g.: int g = (anInt >> 8) & 0xff; MOV EBX,ECX SHR EBX,#8 AND EBX,#255 vs. MOVZX8 EBX,CH or: int b = anInt & 0xff; MOV EBX,ECX AND EBX,#255 vs. MOVZX8 EBX,CL While the latter one is likely to have the same performance, as the resulting micro instructions should be the same. I will run some tests. Do you have a use-case you can send me?

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/337400e7a5dd

PUBLIC COMMENTS All these instructions are used in my changes.

PUBLIC COMMENTS Please note that SPARC has signed loads (which sign-extend into the 64-bit integer registers) for byte, short, and int. They are: LDSB, LDSH, LDSW. SPARC also has unsigned loads (which zero-extend): LDUB, LDUH, LDUW. Of course, SPARC also has a 64-bit load: LDX.

EVALUATION Some micro benchmarks show a big performance win.

PUBLIC COMMENTS I have to revert that. On 32-bit x86 the LoadUI2L opcode helps a lot.

PUBLIC COMMENTS While implementing LoadUI2L I noticed that it does not make much sense to add that one. On x86_64 there is no such instruction to do that load, because loading an E-register clears the high bits implicitly anyway. And on SPARC all integer loads are unsigned integer loads.