1.1 --- a/src/share/vm/opto/phaseX.cpp Mon Dec 01 09:38:52 2014 -0500 1.2 +++ b/src/share/vm/opto/phaseX.cpp Mon Dec 01 22:27:00 2014 +0100 1.3 @@ -1340,15 +1340,27 @@ 1.4 } 1.5 } 1.6 1.7 - if( use->is_Cmp() ) { // Enable CMP/BOOL optimization 1.8 + uint use_op = use->Opcode(); 1.9 + if(use->is_Cmp()) { // Enable CMP/BOOL optimization 1.10 add_users_to_worklist(use); // Put Bool on worklist 1.11 - // Look for the 'is_x2logic' pattern: "x ? : 0 : 1" and put the 1.12 - // phi merging either 0 or 1 onto the worklist 1.13 if (use->outcnt() > 0) { 1.14 Node* bol = use->raw_out(0); 1.15 if (bol->outcnt() > 0) { 1.16 Node* iff = bol->raw_out(0); 1.17 - if (iff->outcnt() == 2) { 1.18 + if (use_op == Op_CmpI && 1.19 + iff->is_CountedLoopEnd()) { 1.20 + CountedLoopEndNode* cle = iff->as_CountedLoopEnd(); 1.21 + if (cle->limit() == n && cle->phi() != NULL) { 1.22 + // If an opaque node feeds into the limit condition of a 1.23 + // CountedLoop, we need to process the Phi node for the 1.24 + // induction variable when the opaque node is removed: 1.25 + // the range of values taken by the Phi is now known and 1.26 + // so its type is also known. 1.27 + _worklist.push(cle->phi()); 1.28 + } 1.29 + } else if (iff->outcnt() == 2) { 1.30 + // Look for the 'is_x2logic' pattern: "x ? : 0 : 1" and put the 1.31 + // phi merging either 0 or 1 onto the worklist 1.32 Node* ifproj0 = iff->raw_out(0); 1.33 Node* ifproj1 = iff->raw_out(1); 1.34 if (ifproj0->outcnt() > 0 && ifproj1->outcnt() > 0) { 1.35 @@ -1360,9 +1372,26 @@ 1.36 } 1.37 } 1.38 } 1.39 + if (use_op == Op_CmpI) { 1.40 + Node* in1 = use->in(1); 1.41 + for (uint i = 0; i < in1->outcnt(); i++) { 1.42 + if (in1->raw_out(i)->Opcode() == Op_CastII) { 1.43 + Node* castii = in1->raw_out(i); 1.44 + if (castii->in(0) != NULL && castii->in(0)->in(0) != NULL && castii->in(0)->in(0)->is_If()) { 1.45 + Node* ifnode = castii->in(0)->in(0); 1.46 + if (ifnode->in(1) != NULL && ifnode->in(1)->in(1) == use) { 1.47 + // Reprocess a CastII node that may depend on an 1.48 + // opaque node value when the opaque node is 1.49 + // removed. In case it carries a dependency we can do 1.50 + // a better job of computing its type. 1.51 + _worklist.push(castii); 1.52 + } 1.53 + } 1.54 + } 1.55 + } 1.56 + } 1.57 } 1.58 1.59 - uint use_op = use->Opcode(); 1.60 // If changed Cast input, check Phi users for simple cycles 1.61 if( use->is_ConstraintCast() || use->is_CheckCastPP() ) { 1.62 for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {