1630 Node * n = predicate_opaque1_node(i-1); |
1630 Node * n = predicate_opaque1_node(i-1); |
1631 assert(n->Opcode() == Op_Opaque1, "must be"); |
1631 assert(n->Opcode() == Op_Opaque1, "must be"); |
1632 igvn.replace_node(n, n->in(1)); |
1632 igvn.replace_node(n, n->in(1)); |
1633 } |
1633 } |
1634 assert(predicate_count()==0, "should be clean!"); |
1634 assert(predicate_count()==0, "should be clean!"); |
1635 igvn.optimize(); |
|
1636 } |
1635 } |
1637 |
1636 |
1638 //------------------------------Optimize--------------------------------------- |
1637 //------------------------------Optimize--------------------------------------- |
1639 // Given a graph, optimize it. |
1638 // Given a graph, optimize it. |
1640 void Compile::Optimize() { |
1639 void Compile::Optimize() { |
1687 // Set loop opts counter |
1686 // Set loop opts counter |
1688 loop_opts_cnt = num_loop_opts(); |
1687 loop_opts_cnt = num_loop_opts(); |
1689 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { |
1688 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { |
1690 { |
1689 { |
1691 TracePhase t2("idealLoop", &_t_idealLoop, true); |
1690 TracePhase t2("idealLoop", &_t_idealLoop, true); |
1692 PhaseIdealLoop ideal_loop( igvn, true, UseLoopPredicate); |
1691 PhaseIdealLoop ideal_loop( igvn, true ); |
1693 loop_opts_cnt--; |
1692 loop_opts_cnt--; |
1694 if (major_progress()) print_method("PhaseIdealLoop 1", 2); |
1693 if (major_progress()) print_method("PhaseIdealLoop 1", 2); |
1695 if (failing()) return; |
1694 if (failing()) return; |
1696 } |
1695 } |
1697 // Loop opts pass if partial peeling occurred in previous pass |
1696 // Loop opts pass if partial peeling occurred in previous pass |
1698 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { |
1697 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { |
1699 TracePhase t3("idealLoop", &_t_idealLoop, true); |
1698 TracePhase t3("idealLoop", &_t_idealLoop, true); |
1700 PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate); |
1699 PhaseIdealLoop ideal_loop( igvn, false ); |
1701 loop_opts_cnt--; |
1700 loop_opts_cnt--; |
1702 if (major_progress()) print_method("PhaseIdealLoop 2", 2); |
1701 if (major_progress()) print_method("PhaseIdealLoop 2", 2); |
1703 if (failing()) return; |
1702 if (failing()) return; |
1704 } |
1703 } |
1705 // Loop opts pass for loop-unrolling before CCP |
1704 // Loop opts pass for loop-unrolling before CCP |
1706 if(major_progress() && (loop_opts_cnt > 0)) { |
1705 if(major_progress() && (loop_opts_cnt > 0)) { |
1707 TracePhase t4("idealLoop", &_t_idealLoop, true); |
1706 TracePhase t4("idealLoop", &_t_idealLoop, true); |
1708 PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate); |
1707 PhaseIdealLoop ideal_loop( igvn, false ); |
1709 loop_opts_cnt--; |
1708 loop_opts_cnt--; |
1710 if (major_progress()) print_method("PhaseIdealLoop 3", 2); |
1709 if (major_progress()) print_method("PhaseIdealLoop 3", 2); |
1711 } |
1710 } |
1712 if (!failing()) { |
1711 if (!failing()) { |
1713 // Verify that last round of loop opts produced a valid graph |
1712 // Verify that last round of loop opts produced a valid graph |
1741 |
1740 |
1742 // Loop transforms on the ideal graph. Range Check Elimination, |
1741 // Loop transforms on the ideal graph. Range Check Elimination, |
1743 // peeling, unrolling, etc. |
1742 // peeling, unrolling, etc. |
1744 if(loop_opts_cnt > 0) { |
1743 if(loop_opts_cnt > 0) { |
1745 debug_only( int cnt = 0; ); |
1744 debug_only( int cnt = 0; ); |
1746 bool loop_predication = UseLoopPredicate; |
|
1747 while(major_progress() && (loop_opts_cnt > 0)) { |
1745 while(major_progress() && (loop_opts_cnt > 0)) { |
1748 TracePhase t2("idealLoop", &_t_idealLoop, true); |
1746 TracePhase t2("idealLoop", &_t_idealLoop, true); |
1749 assert( cnt++ < 40, "infinite cycle in loop optimization" ); |
1747 assert( cnt++ < 40, "infinite cycle in loop optimization" ); |
1750 PhaseIdealLoop ideal_loop( igvn, true, loop_predication); |
1748 PhaseIdealLoop ideal_loop( igvn, true); |
1751 loop_opts_cnt--; |
1749 loop_opts_cnt--; |
1752 if (major_progress()) print_method("PhaseIdealLoop iterations", 2); |
1750 if (major_progress()) print_method("PhaseIdealLoop iterations", 2); |
1753 if (failing()) return; |
1751 if (failing()) return; |
1754 // Perform loop predication optimization during first iteration after CCP. |
|
1755 // After that switch it off and cleanup unused loop predicates. |
|
1756 if (loop_predication) { |
|
1757 loop_predication = false; |
|
1758 cleanup_loop_predicates(igvn); |
|
1759 if (failing()) return; |
|
1760 } |
|
1761 } |
1752 } |
1762 } |
1753 } |
1763 |
1754 |
1764 { |
1755 { |
1765 // Verify that all previous optimizations produced a valid graph |
1756 // Verify that all previous optimizations produced a valid graph |