Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6431243
Votes 0
Synopsis Optimize Integer.rotateLeft()
Category hotspot:compiler2
Reported Against
Release Fixed hs10(b03), 6u4(b03) (Bug ID:2171795) , 7(b03) (Bug ID:2176733)
State 10-Fix Delivered, request for enhancement
Priority: 3-Medium
Related Bugs 6431242
Submit Date 27-MAY-2006
Description
java.lang.Integer implements 32-bit rotation as:

    public static int rotateLeft(int i, int distance) {
        return (i << distance) | (i >>> -distance);
    }

    public static int rotateRight(int i, int distance) {
        return (i >>> distance) | (i << -distance);
    }

x86 includes the ROL and ROR instruction that do just that, but HotSpot currently does not take advantage of them. Note that in many use cases, distance is a compile-time constant.

Similarly for Long.rotateLeft() and Long.rotateRight().
Posted Date : 2006-05-27 02:52:12.0
Work Around
N/A
Evaluation
We can intrinsify rotateleft and rotateRight or do a specific pattern match in Ideal or the .ad file.
*** (#1 of 1): [ UNSAVED ]   xxxxx@xxxxx  
Posted Date : 2006-05-30 22:08:33.0

Add OrINode::Ideal to indentify the pattern
(i << j ) | ( i >>> -j) and (i >>> j ) | ( i<< -j)
and create new nodes RolINode and RorINode to match ROL and ROR on x86 and amd.
Posted Date : 2006-08-23 18:40:07.0

new changes only to i486.ad and amd64.ad. It will match for
i << 1 | i >>> -1       and  i >>> 1 | i << -1   
i << con | i >>> -con   and  i >>> con | i << -con
con << i | con >>> -i   and  con >>> i | con << -1
i << j | i >>> -j       and  i >>> j | i << -j
and switch left and right style. Also, it can match
i << j | i >>> 32-j where j is a int
i << c | i >>> d where c + d = 32
Those cover most of the common cases of bit rotation for optimized native code.
Posted Date : 2006-09-02 00:05:37.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang