src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6705887 Sdiff src/share/vm/opto

src/share/vm/opto/compile.cpp

Print this page




1891     break;
1892 
1893   // Count all double operations that may use FPU
1894   case Op_AddD:
1895   case Op_SubD:
1896   case Op_MulD:
1897   case Op_DivD:
1898   case Op_NegD:
1899   case Op_ModD:
1900   case Op_ConvI2D:
1901   case Op_ConvD2I:
1902   // case Op_ConvL2D: // handled by leaf call
1903   // case Op_ConvD2L: // handled by leaf call
1904   case Op_ConD:
1905   case Op_CmpD:
1906   case Op_CmpD3:
1907     fpu.inc_double_count();
1908     break;
1909   case Op_Opaque1:              // Remove Opaque Nodes before matching
1910   case Op_Opaque2:              // Remove Opaque Nodes before matching
1911     n->replace_by(n->in(1));
1912     break;
1913   case Op_CallStaticJava:
1914   case Op_CallJava:
1915   case Op_CallDynamicJava:
1916     fpu.inc_java_call_count(); // Count java call site;
1917   case Op_CallRuntime:
1918   case Op_CallLeaf:
1919   case Op_CallLeafNoFP: {
1920     assert( n->is_Call(), "" );
1921     CallNode *call = n->as_Call();
1922     // Count call sites where the FP mode bit would have to be flipped.
1923     // Do not count uncommon runtime calls:
1924     // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking,
1925     // _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ...
1926     if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) {
1927       fpu.inc_call_count();   // Count the call site
1928     } else {                  // See if uncommon argument is shared
1929       Node *n = call->in(TypeFunc::Parms);
1930       int nop = n->Opcode();
1931       // Clone shared simple arguments to uncommon calls, item (1).


1984       MemNode *mem  = (MemNode*)n;
1985       // Check to see if address types have grounded out somehow.
1986       const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
1987       assert( !tp || oop_offset_is_sane(tp), "" );
1988     }
1989 #endif
1990     break;
1991   }
1992 
1993   case Op_AddP: {               // Assert sane base pointers
1994     const Node *addp = n->in(AddPNode::Address);
1995     assert( !addp->is_AddP() ||
1996             addp->in(AddPNode::Base)->is_top() || // Top OK for allocation
1997             addp->in(AddPNode::Base) == n->in(AddPNode::Base),
1998             "Base pointers must match" );
1999     break;
2000   }
2001 
2002 #ifdef _LP64
2003   case Op_CmpP:
2004     if( n->in(1)->Opcode() == Op_DecodeN ) {


2005       Compile* C = Compile::current();
2006       Node* in2 = NULL;
2007       if( n->in(2)->Opcode() == Op_DecodeN ) {
2008         in2 = n->in(2)->in(1);
2009       } else if ( n->in(2)->Opcode() == Op_ConP ) {
2010         const Type* t = n->in(2)->bottom_type();
2011         if (t == TypePtr::NULL_PTR) {
2012           Node *in1 = n->in(1);









2013           uint i = 0;
2014           for (; i < in1->outcnt(); i++) {
2015             if (in1->raw_out(i)->is_AddP())
2016               break;
2017           }
2018           if (i >= in1->outcnt()) {
2019             // Don't replace CmpP(o ,null) if 'o' is used in AddP
2020             // to generate implicit NULL check.
2021             in2 = ConNode::make(C, TypeNarrowOop::NULL_PTR);
2022           }

2023         } else if (t->isa_oopptr()) {
2024           in2 = ConNode::make(C, t->is_oopptr()->make_narrowoop());
2025         }
2026       }
2027       if( in2 != NULL ) {
2028         Node* cmpN = new (C, 3) CmpNNode(n->in(1)->in(1), in2);
2029         n->replace_by( cmpN );
2030       }
2031     }
2032 #endif
2033 
2034   case Op_ModI:
2035     if (UseDivMod) {
2036       // Check if a%b and a/b both exist
2037       Node* d = n->find_similar(Op_DivI);
2038       if (d) {
2039         // Replace them with a fused divmod if supported
2040         Compile* C = Compile::current();
2041         if (Matcher::has_match_rule(Op_DivModI)) {
2042           DivModINode* divmod = DivModINode::make(C, n);
2043           d->replace_by(divmod->div_proj());
2044           n->replace_by(divmod->mod_proj());
2045         } else {
2046           // replace a%b with a-((a/b)*b)
2047           Node* mult = new (C, 3) MulINode(d, d->in(2));
2048           Node* sub  = new (C, 3) SubINode(d->in(1), mult);
2049           n->replace_by( sub );
2050         }
2051       }
2052     }
2053     break;
2054 
2055   case Op_ModL:
2056     if (UseDivMod) {
2057       // Check if a%b and a/b both exist
2058       Node* d = n->find_similar(Op_DivL);
2059       if (d) {
2060         // Replace them with a fused divmod if supported
2061         Compile* C = Compile::current();
2062         if (Matcher::has_match_rule(Op_DivModL)) {
2063           DivModLNode* divmod = DivModLNode::make(C, n);
2064           d->replace_by(divmod->div_proj());
2065           n->replace_by(divmod->mod_proj());
2066         } else {
2067           // replace a%b with a-((a/b)*b)
2068           Node* mult = new (C, 3) MulLNode(d, d->in(2));
2069           Node* sub  = new (C, 3) SubLNode(d->in(1), mult);
2070           n->replace_by( sub );
2071         }
2072       }
2073     }
2074     break;
2075 
2076   case Op_Load16B:
2077   case Op_Load8B:
2078   case Op_Load4B:
2079   case Op_Load8S:
2080   case Op_Load4S:
2081   case Op_Load2S:
2082   case Op_Load8C:
2083   case Op_Load4C:
2084   case Op_Load2C:
2085   case Op_Load4I:
2086   case Op_Load2I:
2087   case Op_Load2L:
2088   case Op_Load4F:
2089   case Op_Load2F:
2090   case Op_Load2D:


2096   case Op_Store2C:
2097   case Op_Store4I:
2098   case Op_Store2I:
2099   case Op_Store2L:
2100   case Op_Store4F:
2101   case Op_Store2F:
2102   case Op_Store2D:
2103     break;
2104 
2105   case Op_PackB:
2106   case Op_PackS:
2107   case Op_PackC:
2108   case Op_PackI:
2109   case Op_PackF:
2110   case Op_PackL:
2111   case Op_PackD:
2112     if (n->req()-1 > 2) {
2113       // Replace many operand PackNodes with a binary tree for matching
2114       PackNode* p = (PackNode*) n;
2115       Node* btp = p->binaryTreePack(Compile::current(), 1, n->req());
2116       n->replace_by(btp);
2117     }
2118     break;
2119   default:
2120     assert( !n->is_Call(), "" );
2121     assert( !n->is_Mem(), "" );
2122     break;
2123   }
2124 
2125   // Collect CFG split points
2126   if (n->is_MultiBranch())
2127     fpu._tests.push(n);
2128 }
2129 
2130 //------------------------------final_graph_reshaping_walk---------------------
2131 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2132 // requires that the walk visits a node's inputs before visiting the node.
2133 static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &fpu ) {
2134   fpu._visited.set(root->_idx); // first, mark node as visited
2135   uint cnt = root->req();
2136   Node *n = root;




1891     break;
1892 
1893   // Count all double operations that may use FPU
1894   case Op_AddD:
1895   case Op_SubD:
1896   case Op_MulD:
1897   case Op_DivD:
1898   case Op_NegD:
1899   case Op_ModD:
1900   case Op_ConvI2D:
1901   case Op_ConvD2I:
1902   // case Op_ConvL2D: // handled by leaf call
1903   // case Op_ConvD2L: // handled by leaf call
1904   case Op_ConD:
1905   case Op_CmpD:
1906   case Op_CmpD3:
1907     fpu.inc_double_count();
1908     break;
1909   case Op_Opaque1:              // Remove Opaque Nodes before matching
1910   case Op_Opaque2:              // Remove Opaque Nodes before matching
1911     n->subsume_by(n->in(1));
1912     break;
1913   case Op_CallStaticJava:
1914   case Op_CallJava:
1915   case Op_CallDynamicJava:
1916     fpu.inc_java_call_count(); // Count java call site;
1917   case Op_CallRuntime:
1918   case Op_CallLeaf:
1919   case Op_CallLeafNoFP: {
1920     assert( n->is_Call(), "" );
1921     CallNode *call = n->as_Call();
1922     // Count call sites where the FP mode bit would have to be flipped.
1923     // Do not count uncommon runtime calls:
1924     // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking,
1925     // _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ...
1926     if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) {
1927       fpu.inc_call_count();   // Count the call site
1928     } else {                  // See if uncommon argument is shared
1929       Node *n = call->in(TypeFunc::Parms);
1930       int nop = n->Opcode();
1931       // Clone shared simple arguments to uncommon calls, item (1).


1984       MemNode *mem  = (MemNode*)n;
1985       // Check to see if address types have grounded out somehow.
1986       const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
1987       assert( !tp || oop_offset_is_sane(tp), "" );
1988     }
1989 #endif
1990     break;
1991   }
1992 
1993   case Op_AddP: {               // Assert sane base pointers
1994     const Node *addp = n->in(AddPNode::Address);
1995     assert( !addp->is_AddP() ||
1996             addp->in(AddPNode::Base)->is_top() || // Top OK for allocation
1997             addp->in(AddPNode::Base) == n->in(AddPNode::Base),
1998             "Base pointers must match" );
1999     break;
2000   }
2001 
2002 #ifdef _LP64
2003   case Op_CmpP:
2004     // Do this transformation here to preserve CmpPNode::sub() and
2005     // other TypePtr related Ideal optimizations (for example, ptr nullness).
2006     if( n->in(1)->is_DecodeN() ) {
2007       Compile* C = Compile::current();
2008       Node* in2 = NULL;
2009       if( n->in(2)->is_DecodeN() ) {
2010         in2 = n->in(2)->in(1);
2011       } else if ( n->in(2)->Opcode() == Op_ConP ) {
2012         const Type* t = n->in(2)->bottom_type();
2013         if (t == TypePtr::NULL_PTR) {
2014           Node *in1 = n->in(1);
2015           if (Matcher::clone_shift_expressions) {
2016             // x86, ARM and friends can handle 2 adds in addressing mode.
2017             // Decode a narrow oop and do implicit NULL check in address
2018             // [R12 + narrow_oop_reg<<3 + offset]
2019             in2 = ConNode::make(C, TypeNarrowOop::NULL_PTR);
2020           } else {
2021             // Don't replace CmpP(o ,null) if 'o' is used in AddP
2022             // to generate implicit NULL check on Sparc where
2023             // narrow oops can't be used in address.
2024             uint i = 0;
2025             for (; i < in1->outcnt(); i++) {
2026               if (in1->raw_out(i)->is_AddP())
2027                 break;
2028             }
2029             if (i >= in1->outcnt()) {


2030               in2 = ConNode::make(C, TypeNarrowOop::NULL_PTR);
2031             }
2032           }
2033         } else if (t->isa_oopptr()) {
2034           in2 = ConNode::make(C, t->is_oopptr()->make_narrowoop());
2035         }
2036       }
2037       if( in2 != NULL ) {
2038         Node* cmpN = new (C, 3) CmpNNode(n->in(1)->in(1), in2);
2039         n->subsume_by( cmpN );
2040       }
2041     }
2042 #endif
2043 
2044   case Op_ModI:
2045     if (UseDivMod) {
2046       // Check if a%b and a/b both exist
2047       Node* d = n->find_similar(Op_DivI);
2048       if (d) {
2049         // Replace them with a fused divmod if supported
2050         Compile* C = Compile::current();
2051         if (Matcher::has_match_rule(Op_DivModI)) {
2052           DivModINode* divmod = DivModINode::make(C, n);
2053           d->subsume_by(divmod->div_proj());
2054           n->subsume_by(divmod->mod_proj());
2055         } else {
2056           // replace a%b with a-((a/b)*b)
2057           Node* mult = new (C, 3) MulINode(d, d->in(2));
2058           Node* sub  = new (C, 3) SubINode(d->in(1), mult);
2059           n->subsume_by( sub );
2060         }
2061       }
2062     }
2063     break;
2064 
2065   case Op_ModL:
2066     if (UseDivMod) {
2067       // Check if a%b and a/b both exist
2068       Node* d = n->find_similar(Op_DivL);
2069       if (d) {
2070         // Replace them with a fused divmod if supported
2071         Compile* C = Compile::current();
2072         if (Matcher::has_match_rule(Op_DivModL)) {
2073           DivModLNode* divmod = DivModLNode::make(C, n);
2074           d->subsume_by(divmod->div_proj());
2075           n->subsume_by(divmod->mod_proj());
2076         } else {
2077           // replace a%b with a-((a/b)*b)
2078           Node* mult = new (C, 3) MulLNode(d, d->in(2));
2079           Node* sub  = new (C, 3) SubLNode(d->in(1), mult);
2080           n->subsume_by( sub );
2081         }
2082       }
2083     }
2084     break;
2085 
2086   case Op_Load16B:
2087   case Op_Load8B:
2088   case Op_Load4B:
2089   case Op_Load8S:
2090   case Op_Load4S:
2091   case Op_Load2S:
2092   case Op_Load8C:
2093   case Op_Load4C:
2094   case Op_Load2C:
2095   case Op_Load4I:
2096   case Op_Load2I:
2097   case Op_Load2L:
2098   case Op_Load4F:
2099   case Op_Load2F:
2100   case Op_Load2D:


2106   case Op_Store2C:
2107   case Op_Store4I:
2108   case Op_Store2I:
2109   case Op_Store2L:
2110   case Op_Store4F:
2111   case Op_Store2F:
2112   case Op_Store2D:
2113     break;
2114 
2115   case Op_PackB:
2116   case Op_PackS:
2117   case Op_PackC:
2118   case Op_PackI:
2119   case Op_PackF:
2120   case Op_PackL:
2121   case Op_PackD:
2122     if (n->req()-1 > 2) {
2123       // Replace many operand PackNodes with a binary tree for matching
2124       PackNode* p = (PackNode*) n;
2125       Node* btp = p->binaryTreePack(Compile::current(), 1, n->req());
2126       n->subsume_by(btp);
2127     }
2128     break;
2129   default:
2130     assert( !n->is_Call(), "" );
2131     assert( !n->is_Mem(), "" );
2132     break;
2133   }
2134 
2135   // Collect CFG split points
2136   if (n->is_MultiBranch())
2137     fpu._tests.push(n);
2138 }
2139 
2140 //------------------------------final_graph_reshaping_walk---------------------
2141 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2142 // requires that the walk visits a node's inputs before visiting the node.
2143 static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &fpu ) {
2144   fpu._visited.set(root->_idx); // first, mark node as visited
2145   uint cnt = root->req();
2146   Node *n = root;


src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File