United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6480445 Missed tree flatten opportunity in Direct ByteBuffer addressing
JDK-6480445 : Missed tree flatten opportunity in Direct ByteBuffer addressing

Details
Type:
Bug
Submit Date:
2006-10-10
Status:
Resolved
Updated Date:
2010-05-08
Project Name:
JDK
Resolved Date:
2006-11-14
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs10 (b03)

Related Reports
Backport:
Backport:

Sub Tasks

Description
Missed tree flatten opportunity in Direct ByteBuffer addressing.
(p + k1) + k2  not being folded into p + (k1 + k2) for direct
bytebuffer addresses.

                                    

Comments
EVALUATION

Src:
    private final FloatBuffer byteBuffer = 
         ByteBuffer.allocateDirect(40000).
             order(ByteOrder.nativeOrder()).asFloatBuffer();
    for (int i = 0; i < 10000; i++) {
        byteBuffer.put(i, 1234.5678f);
     }

Before:

0c0   B11: #	B20 B12 <- B10 B12 	Loop: B11-B12 inner stride: not constant main Freq: 291826
0c0   	MOV    [ESP + #28],EAX
0c4   	LEA    EDI,[EAX + ESI << #2]
0c7   	MOV    [EDI],#1234.567749	# store float
0cd   	LEA    ECX,[EDI + #32]
0d0   	MOV    [EDI + #4],#1234.567749	# store float
0d7   	LEA    EBP,[ECX + #16]
0da   	LEA    EBX,[ECX + #8]
0dd   	LEA    EAX,[EBP + #8]
0e0   	MOV    [ESP + #32],EAX
0e4   	LEA    EAX,[EDI + #16]
0e7   	LEA    EDI,[EDI + #8]
0ea   	LEA    EDX,[EAX + #8]
0ed   	MOV    [EDI],#1234.567749	# store float
0f3   	MOV    [EDI + #4],#1234.567749	# store float
0fa   	MOV    [EAX],#1234.567749	# store float
100   	MOV    [EAX + #4],#1234.567749	# store float
107   	MOV    [EDX],#1234.567749	# store float
10d   	MOV    [EDX + #4],#1234.567749	# store float
114   	MOV    [ECX],#1234.567749	# store float
11a   	MOV    [ECX + #4],#1234.567749	# store float
121   	MOV    [EBX],#1234.567749	# store float
127   	MOV    [EBX + #4],#1234.567749	# store float
12e   	MOV    [EBP],#1234.567749	# store float
135   	MOV    [EBP + #4],#1234.567749	# store float
13c   	MOV    EBX,[ESP + #32]
140   	MOV    [EBX],#1234.567749	# store float
146   	MOV    ECX,EBX
148   	MOV    [ECX + #4],#1234.567749	# store float
14f   	ADD    ESI,#16
152   	CMP    ESI,[ESP + #44]
156   	Jge    B20	# Loop end  P=0.000099 C=291840.000000
156
15c   B12: #	B11 <- B11  Freq: 335583
15c   	MOV    EAX,[ESP + #28]
160   	JMP    B11

After:

0b0   B11: #	B11 B12 <- B10 B11 	Loop: B11-B11 inner stride: not constant main Freq: 371694
0b0   	LEA    ESI,[EAX + EBX << #2]
0b3   	MOV    [ESI],#1234.567749	# store float
0b9   	MOV    [ESI + #4],#1234.567749	# store float
0c0   	MOV    [ESI + #8],#1234.567749	# store float
0c7   	MOV    [ESI + #12],#1234.567749	# store float
0ce   	MOV    [ESI + #16],#1234.567749	# store float
0d5   	MOV    [ESI + #20],#1234.567749	# store float
0dc   	MOV    [ESI + #24],#1234.567749	# store float
0e3   	MOV    [ESI + #28],#1234.567749	# store float
0ea   	MOV    [ESI + #32],#1234.567749	# store float
0f1   	MOV    [ESI + #36],#1234.567749	# store float
0f8   	MOV    [ESI + #40],#1234.567749	# store float
0ff   	MOV    [ESI + #44],#1234.567749	# store float
106   	MOV    [ESI + #48],#1234.567749	# store float
10d   	MOV    [ESI + #52],#1234.567749	# store float
114   	MOV    [ESI + #56],#1234.567749	# store float
11b   	MOV    [ESI + #60],#1234.567749	# store float
122   	ADD    EBX,#16
125   	CMP    EBX,EBP
127   	Jlt,s  B11  P=0.999900 C=371712.000000
                                     
2006-10-10
SUGGESTED FIX

*** /tmp/geta11449	Tue Oct 10 14:54:15 2006
--- addnode.cpp	Tue Oct 10 14:49:43 2006
***************
*** 475,481 ****
  
    // If the left input is an add of a constant, flatten the expression tree.
    const Node *n = in(Address);
!   if( n->is_AddP() && n->in(Base) != phase->C->top() ) {
      const AddPNode *addp = n->as_AddP(); // Left input is an AddP
      assert( !addp->in(Address)->is_AddP() || 
               addp->in(Address)->as_AddP() != addp,
--- 475,481 ----
  
    // If the left input is an add of a constant, flatten the expression tree.
    const Node *n = in(Address);
!   if( n->is_AddP() && n->in(Base) == in(Base) ) {
      const AddPNode *addp = n->as_AddP(); // Left input is an AddP
      assert( !addp->in(Address)->is_AddP() || 
               addp->in(Address)->as_AddP() != addp,
                                     
2006-10-10
SUGGESTED FIX

http://analemma.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2006/20061012073853.nips.bug6480445/workspace/webrevs/webrev-2006.10.12/index.html
                                     
2006-10-12



Hardware and Software, Engineered to Work Together