1437 VectorSet visited(arena); 1438 visited.set(loop_head->_idx); 1439 rpo( loop_head, stack, visited, rpo_list ); 1440 dump(loop, rpo_list.size(), rpo_list ); 1441 } 1442 #endif 1443 1444 // Remember loop node count before unrolling to detect 1445 // if rounds of unroll,optimize are making progress 1446 loop_head->set_node_count_before_unroll(loop->_body.size()); 1447 1448 Node *ctrl = loop_head->in(LoopNode::EntryControl); 1449 Node *limit = loop_head->limit(); 1450 Node *init = loop_head->init_trip(); 1451 Node *stride = loop_head->stride(); 1452 1453 Node *opaq = NULL; 1454 if (adjust_min_trip) { // If not maximally unrolling, need adjustment 1455 // Search for zero-trip guard. 1456 assert( loop_head->is_main_loop(), "" ); 1457 assert( ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, "" ); 1458 Node *iff = ctrl->in(0); 1459 assert( iff->Opcode() == Op_If, "" ); 1460 Node *bol = iff->in(1); 1461 assert( bol->Opcode() == Op_Bool, "" ); 1462 Node *cmp = bol->in(1); 1463 assert( cmp->Opcode() == Op_CmpI, "" ); 1464 opaq = cmp->in(2); 1465 // Occasionally it's possible for a zero-trip guard Opaque1 node to be 1466 // optimized away and then another round of loop opts attempted. 1467 // We can not optimize this particular loop in that case. 1468 if (opaq->Opcode() != Op_Opaque1) 1469 return; // Cannot find zero-trip guard! Bail out! 1470 // Zero-trip test uses an 'opaque' node which is not shared. 1471 assert(opaq->outcnt() == 1 && opaq->in(1) == limit, ""); 1472 } 1473 1474 C->set_major_progress(); 1475 1476 Node* new_limit = NULL; 1477 if (UnrollLimitCheck) { 1478 int stride_con = stride->get_int(); 1479 int stride_p = (stride_con > 0) ? stride_con : -stride_con; 1480 uint old_trip_count = loop_head->trip_count(); 1481 // Verify that unroll policy result is still valid. 1482 assert(old_trip_count > 1 && 1483 (!adjust_min_trip || stride_p <= (1<<3)*loop_head->unrolled_count()), "sanity"); | 1437 VectorSet visited(arena); 1438 visited.set(loop_head->_idx); 1439 rpo( loop_head, stack, visited, rpo_list ); 1440 dump(loop, rpo_list.size(), rpo_list ); 1441 } 1442 #endif 1443 1444 // Remember loop node count before unrolling to detect 1445 // if rounds of unroll,optimize are making progress 1446 loop_head->set_node_count_before_unroll(loop->_body.size()); 1447 1448 Node *ctrl = loop_head->in(LoopNode::EntryControl); 1449 Node *limit = loop_head->limit(); 1450 Node *init = loop_head->init_trip(); 1451 Node *stride = loop_head->stride(); 1452 1453 Node *opaq = NULL; 1454 if (adjust_min_trip) { // If not maximally unrolling, need adjustment 1455 // Search for zero-trip guard. 1456 assert( loop_head->is_main_loop(), "" ); 1457 // In some cases, the shape of the graph does not match the shape 1458 // outlined below (because other optimizations, e.g., split-if and loop 1459 // peeling have transformed it). Loop unrolling is not possible in these 1460 // cases, so give up on the attempt to unroll the loop (but still continue 1461 // compilation). 1462 if (ctrl->Opcode() != Op_IfTrue && ctrl->Opcode() != Op_IfFalse) { 1463 return; 1464 } 1465 Node *iff = ctrl->in(0); 1466 if (iff->Opcode() != Op_If) { 1467 return; 1468 } 1469 Node *bol = iff->in(1); 1470 if (bol->Opcode() != Op_Bool) { 1471 return; 1472 } 1473 Node *cmp = bol->in(1); 1474 if (cmp->Opcode() != Op_CmpI) { 1475 return; 1476 } 1477 opaq = cmp->in(2); 1478 // Occasionally it's possible for a zero-trip guard Opaque1 node to be 1479 // optimized away and then another round of loop opts attempted. 1480 // We can not optimize this particular loop in that case. 1481 if (opaq->Opcode() != Op_Opaque1) 1482 return; // Cannot find zero-trip guard! Bail out! 1483 // Zero-trip test uses an 'opaque' node which is not shared. 1484 assert(opaq->outcnt() == 1 && opaq->in(1) == limit, ""); 1485 } 1486 1487 C->set_major_progress(); 1488 1489 Node* new_limit = NULL; 1490 if (UnrollLimitCheck) { 1491 int stride_con = stride->get_int(); 1492 int stride_p = (stride_con > 0) ? stride_con : -stride_con; 1493 uint old_trip_count = loop_head->trip_count(); 1494 // Verify that unroll policy result is still valid. 1495 assert(old_trip_count > 1 && 1496 (!adjust_min_trip || stride_p <= (1<<3)*loop_head->unrolled_count()), "sanity"); |