Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/ifnode.cpp @ 6144:5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
Summary: replace frequent C2 optimizer code patterns with new methods calls
Reviewed-by: kvn, twisti
Contributed-by: vladimir.x.ivanov@oracle.com
author | kvn |
---|---|
date | Tue, 12 Jun 2012 16:23:31 -0700 |
parents | c96c3eb1efae |
children | e626685e9f6c |
comparison
equal
deleted
inserted
replaced
6143:8b0a4867acf0 | 6144:5e990493719e |
---|---|
336 // The 'cmp' got cloned, but CastPP/IIs need to be moved. | 336 // The 'cmp' got cloned, but CastPP/IIs need to be moved. |
337 Node *phi_s = NULL; // do not construct unless needed | 337 Node *phi_s = NULL; // do not construct unless needed |
338 Node *phi_f = NULL; // do not construct unless needed | 338 Node *phi_f = NULL; // do not construct unless needed |
339 for (DUIterator_Last i2min, i2 = phi->last_outs(i2min); i2 >= i2min; --i2) { | 339 for (DUIterator_Last i2min, i2 = phi->last_outs(i2min); i2 >= i2min; --i2) { |
340 Node* v = phi->last_out(i2);// User of the phi | 340 Node* v = phi->last_out(i2);// User of the phi |
341 igvn->hash_delete(v); // Have to fixup other Phi users | 341 igvn->rehash_node_delayed(v); // Have to fixup other Phi users |
342 igvn->_worklist.push(v); | |
343 uint vop = v->Opcode(); | 342 uint vop = v->Opcode(); |
344 Node *proj = NULL; | 343 Node *proj = NULL; |
345 if( vop == Op_Phi ) { // Remote merge point | 344 if( vop == Op_Phi ) { // Remote merge point |
346 Node *r = v->in(0); | 345 Node *r = v->in(0); |
347 for (uint i3 = 1; i3 < r->req(); i3++) | 346 for (uint i3 = 1; i3 < r->req(); i3++) |
550 new_cmp = gvn->transform(new_cmp); | 549 new_cmp = gvn->transform(new_cmp); |
551 // See if no need to adjust the existing check | 550 // See if no need to adjust the existing check |
552 if( new_cmp == cmp ) return; | 551 if( new_cmp == cmp ) return; |
553 // Else, adjust existing check | 552 // Else, adjust existing check |
554 Node *new_bol = gvn->transform( new (gvn->C, 2) BoolNode( new_cmp, bol->as_Bool()->_test._test ) ); | 553 Node *new_bol = gvn->transform( new (gvn->C, 2) BoolNode( new_cmp, bol->as_Bool()->_test._test ) ); |
555 igvn->hash_delete( iff ); | 554 igvn->rehash_node_delayed( iff ); |
556 iff->set_req_X( 1, new_bol, igvn ); | 555 iff->set_req_X( 1, new_bol, igvn ); |
557 igvn->_worklist.push( iff ); | |
558 } | 556 } |
559 | 557 |
560 //------------------------------up_one_dom------------------------------------- | 558 //------------------------------up_one_dom------------------------------------- |
561 // Walk up the dominator tree one step. Return NULL at root or true | 559 // Walk up the dominator tree one step. Return NULL at root or true |
562 // complex merges. Skips through small diamonds. | 560 // complex merges. Skips through small diamonds. |
730 // Merge the two compares into a single unsigned compare by building (CmpU (n - lo) hi) | 728 // Merge the two compares into a single unsigned compare by building (CmpU (n - lo) hi) |
731 BoolTest::mask cond = fail->as_Proj()->_con ? BoolTest::lt : BoolTest::ge; | 729 BoolTest::mask cond = fail->as_Proj()->_con ? BoolTest::lt : BoolTest::ge; |
732 Node* adjusted = phase->transform(new (phase->C, 3) SubINode(n, phase->intcon(failtype->_lo))); | 730 Node* adjusted = phase->transform(new (phase->C, 3) SubINode(n, phase->intcon(failtype->_lo))); |
733 Node* newcmp = phase->transform(new (phase->C, 3) CmpUNode(adjusted, phase->intcon(bound))); | 731 Node* newcmp = phase->transform(new (phase->C, 3) CmpUNode(adjusted, phase->intcon(bound))); |
734 Node* newbool = phase->transform(new (phase->C, 2) BoolNode(newcmp, cond)); | 732 Node* newbool = phase->transform(new (phase->C, 2) BoolNode(newcmp, cond)); |
735 phase->hash_delete(dom_iff); | 733 phase->is_IterGVN()->replace_input_of(dom_iff, 1, phase->intcon(ctrl->as_Proj()->_con)); |
736 dom_iff->set_req(1, phase->intcon(ctrl->as_Proj()->_con)); | |
737 phase->is_IterGVN()->_worklist.push(dom_iff); | |
738 phase->hash_delete(this); | 734 phase->hash_delete(this); |
739 set_req(1, newbool); | 735 set_req(1, newbool); |
740 return this; | 736 return this; |
741 } | 737 } |
742 if (failtype->_lo > failtype->_hi) { | 738 if (failtype->_lo > failtype->_hi) { |
1040 | 1036 |
1041 // For each child of an IfTrue/IfFalse projection, reroute. | 1037 // For each child of an IfTrue/IfFalse projection, reroute. |
1042 // Loop ends when projection has no more uses. | 1038 // Loop ends when projection has no more uses. |
1043 for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) { | 1039 for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) { |
1044 Node* s = ifp->last_out(j); // Get child of IfTrue/IfFalse | 1040 Node* s = ifp->last_out(j); // Get child of IfTrue/IfFalse |
1045 igvn->hash_delete(s); // Yank from hash table before edge hacking | |
1046 if( !s->depends_only_on_test() ) { | 1041 if( !s->depends_only_on_test() ) { |
1047 // Find the control input matching this def-use edge. | 1042 // Find the control input matching this def-use edge. |
1048 // For Regions it may not be in slot 0. | 1043 // For Regions it may not be in slot 0. |
1049 uint l; | 1044 uint l; |
1050 for( l = 0; s->in(l) != ifp; l++ ) { } | 1045 for( l = 0; s->in(l) != ifp; l++ ) { } |
1051 s->set_req(l, ctrl_target); | 1046 igvn->replace_input_of(s, l, ctrl_target); |
1052 } else { // Else, for control producers, | 1047 } else { // Else, for control producers, |
1053 s->set_req(0, data_target); // Move child to data-target | 1048 igvn->replace_input_of(s, 0, data_target); // Move child to data-target |
1054 } | 1049 } |
1055 igvn->_worklist.push(s); // Revisit collapsed Phis | |
1056 } // End for each child of a projection | 1050 } // End for each child of a projection |
1057 | 1051 |
1058 igvn->remove_dead_node(ifp); | 1052 igvn->remove_dead_node(ifp); |
1059 } // End for each IfTrue/IfFalse child of If | 1053 } // End for each IfTrue/IfFalse child of If |
1060 | 1054 |