23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/barrierSet.hpp" 27 #include "gc/shared/c2/barrierSetC2.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/resourceArea.hpp" 30 #include "opto/addnode.hpp" 31 #include "opto/callnode.hpp" 32 #include "opto/castnode.hpp" 33 #include "opto/connode.hpp" 34 #include "opto/castnode.hpp" 35 #include "opto/divnode.hpp" 36 #include "opto/loopnode.hpp" 37 #include "opto/matcher.hpp" 38 #include "opto/mulnode.hpp" 39 #include "opto/movenode.hpp" 40 #include "opto/opaquenode.hpp" 41 #include "opto/rootnode.hpp" 42 #include "opto/subnode.hpp" 43 #include "utilities/macros.hpp" 44 #if INCLUDE_ZGC 45 #include "gc/z/c2/zBarrierSetC2.hpp" 46 #endif 47 48 //============================================================================= 49 //------------------------------split_thru_phi--------------------------------- 50 // Split Node 'n' through merge point if there is enough win. 51 Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) { 52 if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::LONG) { 53 // ConvI2L may have type information on it which is unsafe to push up 54 // so disable this for now 55 return NULL; 56 } 57 58 // Splitting range check CastIIs through a loop induction Phi can 59 // cause new Phis to be created that are left unrelated to the loop 60 // induction Phi and prevent optimizations (vectorization) 61 if (n->Opcode() == Op_CastII && n->as_CastII()->has_range_check() && 62 region->is_CountedLoop() && n->in(1) == region->as_CountedLoop()->phi()) { 63 return NULL; 64 } 65 66 int wins = 0; 67 assert(!n->is_CFG(), ""); 68 assert(region->is_Region(), ""); 69 70 const Type* type = n->bottom_type(); 71 const TypeOopPtr *t_oop = _igvn.type(n)->isa_oopptr(); 72 Node *phi; 73 if (t_oop != NULL && t_oop->is_known_instance_field()) { 74 int iid = t_oop->instance_id(); 75 int index = C->get_alias_index(t_oop); 76 int offset = t_oop->offset(); 77 phi = new PhiNode(region, type, NULL, iid, index, offset); 78 } else { 79 phi = PhiNode::make_blank(region, n); 80 } 81 uint old_unique = C->unique(); 82 for (uint i = 1; i < region->req(); i++) { 83 Node *x; 84 Node* the_clone = NULL; 85 if (region->in(i) == C->top()) { 1431 1432 // Some institutional knowledge is needed here: 'x' is 1433 // yanked because if the optimizer runs GVN on it all the 1434 // cloned x's will common up and undo this optimization and 1435 // be forced back in the loop. This is annoying because it 1436 // makes +VerifyOpto report false-positives on progress. I 1437 // tried setting control edges on the x's to force them to 1438 // not combine, but the matching gets worried when it tries 1439 // to fold a StoreP and an AddP together (as part of an 1440 // address expression) and the AddP and StoreP have 1441 // different controls. 1442 if (!x->is_Load() && !x->is_DecodeNarrowPtr()) _igvn._worklist.yank(x); 1443 } 1444 _igvn.remove_dead_node(n); 1445 } 1446 } 1447 } 1448 } 1449 1450 try_move_store_after_loop(n); 1451 1452 // Check for Opaque2's who's loop has disappeared - who's input is in the 1453 // same loop nest as their output. Remove 'em, they are no longer useful. 1454 if( n_op == Op_Opaque2 && 1455 n->in(1) != NULL && 1456 get_loop(get_ctrl(n)) == get_loop(get_ctrl(n->in(1))) ) { 1457 _igvn.replace_node( n, n->in(1) ); 1458 } 1459 1460 #if INCLUDE_ZGC 1461 if (UseZGC) { 1462 ZBarrierSetC2::loop_optimize_gc_barrier(this, n, last_round); 1463 } 1464 #endif 1465 } 1466 1467 //------------------------------split_if_with_blocks--------------------------- 1468 // Check for aggressive application of 'split-if' optimization, 1469 // using basic block level info. 1470 void PhaseIdealLoop::split_if_with_blocks(VectorSet &visited, Node_Stack &nstack, bool last_round) { | 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/barrierSet.hpp" 27 #include "gc/shared/c2/barrierSetC2.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/resourceArea.hpp" 30 #include "opto/addnode.hpp" 31 #include "opto/callnode.hpp" 32 #include "opto/castnode.hpp" 33 #include "opto/connode.hpp" 34 #include "opto/castnode.hpp" 35 #include "opto/divnode.hpp" 36 #include "opto/loopnode.hpp" 37 #include "opto/matcher.hpp" 38 #include "opto/mulnode.hpp" 39 #include "opto/movenode.hpp" 40 #include "opto/opaquenode.hpp" 41 #include "opto/rootnode.hpp" 42 #include "opto/subnode.hpp" 43 #include "opto/valuetypenode.hpp" 44 #include "utilities/macros.hpp" 45 #if INCLUDE_ZGC 46 #include "gc/z/c2/zBarrierSetC2.hpp" 47 #endif 48 49 //============================================================================= 50 //------------------------------split_thru_phi--------------------------------- 51 // Split Node 'n' through merge point if there is enough win. 52 Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) { 53 if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::LONG) { 54 // ConvI2L may have type information on it which is unsafe to push up 55 // so disable this for now 56 return NULL; 57 } 58 59 // Splitting range check CastIIs through a loop induction Phi can 60 // cause new Phis to be created that are left unrelated to the loop 61 // induction Phi and prevent optimizations (vectorization) 62 if (n->Opcode() == Op_CastII && n->as_CastII()->has_range_check() && 63 region->is_CountedLoop() && n->in(1) == region->as_CountedLoop()->phi()) { 64 return NULL; 65 } 66 67 // Value types should not be split through Phis because they cannot be merged 68 // through Phi nodes but each value input needs to be merged individually. 69 if (n->is_ValueType()) { 70 return NULL; 71 } 72 73 int wins = 0; 74 assert(!n->is_CFG(), ""); 75 assert(region->is_Region(), ""); 76 77 const Type* type = n->bottom_type(); 78 const TypeOopPtr *t_oop = _igvn.type(n)->isa_oopptr(); 79 Node *phi; 80 if (t_oop != NULL && t_oop->is_known_instance_field()) { 81 int iid = t_oop->instance_id(); 82 int index = C->get_alias_index(t_oop); 83 int offset = t_oop->offset(); 84 phi = new PhiNode(region, type, NULL, iid, index, offset); 85 } else { 86 phi = PhiNode::make_blank(region, n); 87 } 88 uint old_unique = C->unique(); 89 for (uint i = 1; i < region->req(); i++) { 90 Node *x; 91 Node* the_clone = NULL; 92 if (region->in(i) == C->top()) { 1438 1439 // Some institutional knowledge is needed here: 'x' is 1440 // yanked because if the optimizer runs GVN on it all the 1441 // cloned x's will common up and undo this optimization and 1442 // be forced back in the loop. This is annoying because it 1443 // makes +VerifyOpto report false-positives on progress. I 1444 // tried setting control edges on the x's to force them to 1445 // not combine, but the matching gets worried when it tries 1446 // to fold a StoreP and an AddP together (as part of an 1447 // address expression) and the AddP and StoreP have 1448 // different controls. 1449 if (!x->is_Load() && !x->is_DecodeNarrowPtr()) _igvn._worklist.yank(x); 1450 } 1451 _igvn.remove_dead_node(n); 1452 } 1453 } 1454 } 1455 } 1456 1457 try_move_store_after_loop(n); 1458 1459 // Remove multiple allocations of the same value type 1460 if (n->is_ValueType() && EliminateAllocations) { 1461 n->as_ValueType()->remove_redundant_allocations(&_igvn, this); 1462 return; // n is now dead 1463 } 1464 1465 // Check for Opaque2's who's loop has disappeared - who's input is in the 1466 // same loop nest as their output. Remove 'em, they are no longer useful. 1467 if( n_op == Op_Opaque2 && 1468 n->in(1) != NULL && 1469 get_loop(get_ctrl(n)) == get_loop(get_ctrl(n->in(1))) ) { 1470 _igvn.replace_node( n, n->in(1) ); 1471 } 1472 1473 #if INCLUDE_ZGC 1474 if (UseZGC) { 1475 ZBarrierSetC2::loop_optimize_gc_barrier(this, n, last_round); 1476 } 1477 #endif 1478 } 1479 1480 //------------------------------split_if_with_blocks--------------------------- 1481 // Check for aggressive application of 'split-if' optimization, 1482 // using basic block level info. 1483 void PhaseIdealLoop::split_if_with_blocks(VectorSet &visited, Node_Stack &nstack, bool last_round) { |