102 uint proj_index = 1; // region's edge corresponding to uncommon_proj |
102 uint proj_index = 1; // region's edge corresponding to uncommon_proj |
103 if (!rgn->is_Region()) { // create a region to guard the call |
103 if (!rgn->is_Region()) { // create a region to guard the call |
104 assert(rgn->is_Call(), "must be call uct"); |
104 assert(rgn->is_Call(), "must be call uct"); |
105 CallNode* call = rgn->as_Call(); |
105 CallNode* call = rgn->as_Call(); |
106 IdealLoopTree* loop = get_loop(call); |
106 IdealLoopTree* loop = get_loop(call); |
107 rgn = new (C) RegionNode(1); |
107 rgn = new RegionNode(1); |
108 rgn->add_req(uncommon_proj); |
108 rgn->add_req(uncommon_proj); |
109 register_control(rgn, loop, uncommon_proj); |
109 register_control(rgn, loop, uncommon_proj); |
110 _igvn.hash_delete(call); |
110 _igvn.hash_delete(call); |
111 call->set_req(0, rgn); |
111 call->set_req(0, rgn); |
112 // When called from beautify_loops() idom is not constructed yet. |
112 // When called from beautify_loops() idom is not constructed yet. |
128 // Create new_iff |
128 // Create new_iff |
129 IdealLoopTree* lp = get_loop(entry); |
129 IdealLoopTree* lp = get_loop(entry); |
130 IfNode *new_iff = iff->clone()->as_If(); |
130 IfNode *new_iff = iff->clone()->as_If(); |
131 new_iff->set_req(0, entry); |
131 new_iff->set_req(0, entry); |
132 register_control(new_iff, lp, entry); |
132 register_control(new_iff, lp, entry); |
133 Node *if_cont = new (C) IfTrueNode(new_iff); |
133 Node *if_cont = new IfTrueNode(new_iff); |
134 Node *if_uct = new (C) IfFalseNode(new_iff); |
134 Node *if_uct = new IfFalseNode(new_iff); |
135 if (cont_proj->is_IfFalse()) { |
135 if (cont_proj->is_IfFalse()) { |
136 // Swap |
136 // Swap |
137 Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; |
137 Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; |
138 } |
138 } |
139 register_control(if_cont, lp, new_iff); |
139 register_control(if_cont, lp, new_iff); |
189 |
189 |
190 uint proj_index = 1; // region's edge corresponding to uncommon_proj |
190 uint proj_index = 1; // region's edge corresponding to uncommon_proj |
191 if (!rgn->is_Region()) { // create a region to guard the call |
191 if (!rgn->is_Region()) { // create a region to guard the call |
192 assert(rgn->is_Call(), "must be call uct"); |
192 assert(rgn->is_Call(), "must be call uct"); |
193 CallNode* call = rgn->as_Call(); |
193 CallNode* call = rgn->as_Call(); |
194 rgn = new (C) RegionNode(1); |
194 rgn = new RegionNode(1); |
195 register_new_node_with_optimizer(rgn); |
195 register_new_node_with_optimizer(rgn); |
196 rgn->add_req(uncommon_proj); |
196 rgn->add_req(uncommon_proj); |
197 hash_delete(call); |
197 hash_delete(call); |
198 call->set_req(0, rgn); |
198 call->set_req(0, rgn); |
199 } else { |
199 } else { |
206 // Create new_iff in new location. |
206 // Create new_iff in new location. |
207 IfNode *new_iff = iff->clone()->as_If(); |
207 IfNode *new_iff = iff->clone()->as_If(); |
208 new_iff->set_req(0, new_entry); |
208 new_iff->set_req(0, new_entry); |
209 |
209 |
210 register_new_node_with_optimizer(new_iff); |
210 register_new_node_with_optimizer(new_iff); |
211 Node *if_cont = new (C) IfTrueNode(new_iff); |
211 Node *if_cont = new IfTrueNode(new_iff); |
212 Node *if_uct = new (C) IfFalseNode(new_iff); |
212 Node *if_uct = new IfFalseNode(new_iff); |
213 if (cont_proj->is_IfFalse()) { |
213 if (cont_proj->is_IfFalse()) { |
214 // Swap |
214 // Swap |
215 Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; |
215 Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; |
216 } |
216 } |
217 register_new_node_with_optimizer(if_cont); |
217 register_new_node_with_optimizer(if_cont); |
252 IfNode* iff = new_predicate_proj->in(0)->as_If(); |
252 IfNode* iff = new_predicate_proj->in(0)->as_If(); |
253 Node* ctrl = iff->in(0); |
253 Node* ctrl = iff->in(0); |
254 |
254 |
255 // Match original condition since predicate's projections could be swapped. |
255 // Match original condition since predicate's projections could be swapped. |
256 assert(predicate_proj->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be"); |
256 assert(predicate_proj->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be"); |
257 Node* opq = new (igvn->C) Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1)); |
257 Node* opq = new Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1)); |
258 igvn->C->add_predicate_opaq(opq); |
258 igvn->C->add_predicate_opaq(opq); |
259 |
259 |
260 Node* bol = new (igvn->C) Conv2BNode(opq); |
260 Node* bol = new Conv2BNode(opq); |
261 if (loop_phase != NULL) { |
261 if (loop_phase != NULL) { |
262 loop_phase->register_new_node(opq, ctrl); |
262 loop_phase->register_new_node(opq, ctrl); |
263 loop_phase->register_new_node(bol, ctrl); |
263 loop_phase->register_new_node(bol, ctrl); |
264 } else { |
264 } else { |
265 igvn->register_new_node_with_optimizer(opq); |
265 igvn->register_new_node_with_optimizer(opq); |
603 if (LoopLimitCheck) { |
603 if (LoopLimitCheck) { |
604 // With LoopLimitCheck limit is not exact. |
604 // With LoopLimitCheck limit is not exact. |
605 // Calculate exact limit here. |
605 // Calculate exact limit here. |
606 // Note, counted loop's test is '<' or '>'. |
606 // Note, counted loop's test is '<' or '>'. |
607 limit = exact_limit(loop); |
607 limit = exact_limit(loop); |
608 max_idx_expr = new (C) SubINode(limit, stride); |
608 max_idx_expr = new SubINode(limit, stride); |
609 register_new_node(max_idx_expr, ctrl); |
609 register_new_node(max_idx_expr, ctrl); |
610 if (TraceLoopPredicate) predString->print("(limit - stride) "); |
610 if (TraceLoopPredicate) predString->print("(limit - stride) "); |
611 } else { |
611 } else { |
612 max_idx_expr = new (C) SubINode(limit, stride); |
612 max_idx_expr = new SubINode(limit, stride); |
613 register_new_node(max_idx_expr, ctrl); |
613 register_new_node(max_idx_expr, ctrl); |
614 if (TraceLoopPredicate) predString->print("(limit - stride) "); |
614 if (TraceLoopPredicate) predString->print("(limit - stride) "); |
615 } |
615 } |
616 } else { |
616 } else { |
617 if (TraceLoopPredicate) predString->print("init "); |
617 if (TraceLoopPredicate) predString->print("init "); |
618 } |
618 } |
619 |
619 |
620 if (scale != 1) { |
620 if (scale != 1) { |
621 ConNode* con_scale = _igvn.intcon(scale); |
621 ConNode* con_scale = _igvn.intcon(scale); |
622 max_idx_expr = new (C) MulINode(max_idx_expr, con_scale); |
622 max_idx_expr = new MulINode(max_idx_expr, con_scale); |
623 register_new_node(max_idx_expr, ctrl); |
623 register_new_node(max_idx_expr, ctrl); |
624 if (TraceLoopPredicate) predString->print("* %d ", scale); |
624 if (TraceLoopPredicate) predString->print("* %d ", scale); |
625 } |
625 } |
626 |
626 |
627 if (offset && (!offset->is_Con() || offset->get_int() != 0)){ |
627 if (offset && (!offset->is_Con() || offset->get_int() != 0)){ |
628 max_idx_expr = new (C) AddINode(max_idx_expr, offset); |
628 max_idx_expr = new AddINode(max_idx_expr, offset); |
629 register_new_node(max_idx_expr, ctrl); |
629 register_new_node(max_idx_expr, ctrl); |
630 if (TraceLoopPredicate) |
630 if (TraceLoopPredicate) |
631 if (offset->is_Con()) predString->print("+ %d ", offset->get_int()); |
631 if (offset->is_Con()) predString->print("+ %d ", offset->get_int()); |
632 else predString->print("+ offset "); |
632 else predString->print("+ offset "); |
633 } |
633 } |
634 |
634 |
635 CmpUNode* cmp = new (C) CmpUNode(max_idx_expr, range); |
635 CmpUNode* cmp = new CmpUNode(max_idx_expr, range); |
636 register_new_node(cmp, ctrl); |
636 register_new_node(cmp, ctrl); |
637 BoolNode* bol = new (C) BoolNode(cmp, BoolTest::lt); |
637 BoolNode* bol = new BoolNode(cmp, BoolTest::lt); |
638 register_new_node(bol, ctrl); |
638 register_new_node(bol, ctrl); |
639 |
639 |
640 if (TraceLoopPredicate) { |
640 if (TraceLoopPredicate) { |
641 predString->print_cr("<u range"); |
641 predString->print_cr("<u range"); |
642 tty->print("%s", predString->as_string()); |
642 tty->print("%s", predString->as_string()); |
748 BoolNode* new_predicate_bol = invar.clone(bol, ctrl)->as_Bool(); |
748 BoolNode* new_predicate_bol = invar.clone(bol, ctrl)->as_Bool(); |
749 |
749 |
750 // Negate test if necessary |
750 // Negate test if necessary |
751 bool negated = false; |
751 bool negated = false; |
752 if (proj->_con != predicate_proj->_con) { |
752 if (proj->_con != predicate_proj->_con) { |
753 new_predicate_bol = new (C) BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate()); |
753 new_predicate_bol = new BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate()); |
754 register_new_node(new_predicate_bol, ctrl); |
754 register_new_node(new_predicate_bol, ctrl); |
755 negated = true; |
755 negated = true; |
756 } |
756 } |
757 IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If(); |
757 IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If(); |
758 _igvn.hash_delete(new_predicate_iff); |
758 _igvn.hash_delete(new_predicate_iff); |