3127 Node *exact_limit = phase->exact_limit(this); |
3127 Node *exact_limit = phase->exact_limit(this); |
3128 if (exact_limit != cl->limit()) { |
3128 if (exact_limit != cl->limit()) { |
3129 // We also need to replace the original limit to collapse loop exit. |
3129 // We also need to replace the original limit to collapse loop exit. |
3130 Node* cmp = cl->loopexit()->cmp_node(); |
3130 Node* cmp = cl->loopexit()->cmp_node(); |
3131 assert(cl->limit() == cmp->in(2), "sanity"); |
3131 assert(cl->limit() == cmp->in(2), "sanity"); |
|
3132 // Duplicate cmp node if it has other users |
|
3133 if (cmp->outcnt() > 1) { |
|
3134 cmp = cmp->clone(); |
|
3135 cmp = phase->_igvn.register_new_node_with_optimizer(cmp); |
|
3136 BoolNode *bol = cl->loopexit()->in(CountedLoopEndNode::TestValue)->as_Bool(); |
|
3137 phase->_igvn.replace_input_of(bol, 1, cmp); // put bol on worklist |
|
3138 } |
3132 phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist |
3139 phase->_igvn._worklist.push(cmp->in(2)); // put limit on worklist |
3133 phase->_igvn.replace_input_of(cmp, 2, exact_limit); // put cmp on worklist |
3140 phase->_igvn.replace_input_of(cmp, 2, exact_limit); // put cmp on worklist |
3134 } |
3141 } |
3135 // Note: the final value after increment should not overflow since |
3142 // Note: the final value after increment should not overflow since |
3136 // counted loop has limit check predicate. |
3143 // counted loop has limit check predicate. |