comparison src/share/vm/opto/loopnode.cpp @ 23660:b5f3a471e646

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 01 Jun 2016 00:11:44 +0200
parents 501f014415d8
children c9035b8e388b
comparison
equal deleted inserted replaced
23411:d7cf78885a3a 23660:b5f3a471e646
683 limit = gvn->transform(new (C) AddINode(span,init_trip)); 683 limit = gvn->transform(new (C) AddINode(span,init_trip));
684 set_subtree_ctrl( limit ); 684 set_subtree_ctrl( limit );
685 685
686 } // LoopLimitCheck 686 } // LoopLimitCheck
687 687
688 // Check for SafePoint on backedge and remove 688 if (!UseCountedLoopSafepoints) {
689 Node *sfpt = x->in(LoopNode::LoopBackControl); 689 // Check for SafePoint on backedge and remove
690 if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) { 690 Node *sfpt = x->in(LoopNode::LoopBackControl);
691 lazy_replace( sfpt, iftrue ); 691 if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) {
692 if (loop->_safepts != NULL) { 692 lazy_replace( sfpt, iftrue );
693 loop->_safepts->yank(sfpt); 693 if (loop->_safepts != NULL) {
694 } 694 loop->_safepts->yank(sfpt);
695 loop->_tail = iftrue; 695 }
696 loop->_tail = iftrue;
697 }
696 } 698 }
697 699
698 // Build a canonical trip test. 700 // Build a canonical trip test.
699 // Clone code, as old values may be in use. 701 // Clone code, as old values may be in use.
700 incr = incr->clone(); 702 incr = incr->clone();
779 // Fix all data nodes placed at the old loop head. 781 // Fix all data nodes placed at the old loop head.
780 // Uses the lazy-update mechanism of 'get_ctrl'. 782 // Uses the lazy-update mechanism of 'get_ctrl'.
781 lazy_replace( x, l ); 783 lazy_replace( x, l );
782 set_idom(l, init_control, dom_depth(x)); 784 set_idom(l, init_control, dom_depth(x));
783 785
784 // Check for immediately preceding SafePoint and remove 786 if (!UseCountedLoopSafepoints) {
785 Node *sfpt2 = le->in(0); 787 // Check for immediately preceding SafePoint and remove
786 if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) { 788 Node *sfpt2 = le->in(0);
787 lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control)); 789 if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) {
788 if (loop->_safepts != NULL) { 790 lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control));
789 loop->_safepts->yank(sfpt2); 791 if (loop->_safepts != NULL) {
792 loop->_safepts->yank(sfpt2);
793 }
790 } 794 }
791 } 795 }
792 796
793 // Free up intermediate goo 797 // Free up intermediate goo
794 _igvn.remove_dead_node(hook); 798 _igvn.remove_dead_node(hook);
1804 continue; 1808 continue;
1805 } 1809 }
1806 } 1810 }
1807 } 1811 }
1808 1812
1813 void IdealLoopTree::remove_safepoints(PhaseIdealLoop* phase, bool keep_one) {
1814 Node* keep = NULL;
1815 if (keep_one) {
1816 // Look for a safepoint on the idom-path.
1817 for (Node* i = tail(); i != _head; i = phase->idom(i)) {
1818 if (i->Opcode() == Op_SafePoint && phase->get_loop(i) == this) {
1819 keep = i;
1820 break; // Found one
1821 }
1822 }
1823 }
1824
1825 // Don't remove any safepoints if it is requested to keep a single safepoint and
1826 // no safepoint was found on idom-path. It is not safe to remove any safepoint
1827 // in this case since there's no safepoint dominating all paths in the loop body.
1828 bool prune = !keep_one || keep != NULL;
1829
1830 // Delete other safepoints in this loop.
1831 Node_List* sfpts = _safepts;
1832 if (prune && sfpts != NULL) {
1833 assert(keep == NULL || keep->Opcode() == Op_SafePoint, "not safepoint");
1834 for (uint i = 0; i < sfpts->size(); i++) {
1835 Node* n = sfpts->at(i);
1836 assert(phase->get_loop(n) == this, "");
1837 if (n != keep && phase->is_deleteable_safept(n)) {
1838 phase->lazy_replace(n, n->in(TypeFunc::Control));
1839 }
1840 }
1841 }
1842 }
1843
1809 //------------------------------counted_loop----------------------------------- 1844 //------------------------------counted_loop-----------------------------------
1810 // Convert to counted loops where possible 1845 // Convert to counted loops where possible
1811 void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) { 1846 void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
1812 1847
1813 // For grins, set the inner-loop flag here 1848 // For grins, set the inner-loop flag here
1815 if (_head->is_Loop()) _head->as_Loop()->set_inner_loop(); 1850 if (_head->is_Loop()) _head->as_Loop()->set_inner_loop();
1816 } 1851 }
1817 1852
1818 if (_head->is_CountedLoop() || 1853 if (_head->is_CountedLoop() ||
1819 phase->is_counted_loop(_head, this)) { 1854 phase->is_counted_loop(_head, this)) {
1820 _has_sfpt = 1; // Indicate we do not need a safepoint here 1855
1821 1856 if (!UseCountedLoopSafepoints) {
1822 // Look for safepoints to remove. 1857 // Indicate we do not need a safepoint here
1823 Node_List* sfpts = _safepts; 1858 _has_sfpt = 1;
1824 if (sfpts != NULL) { 1859 }
1825 for (uint i = 0; i < sfpts->size(); i++) { 1860
1826 Node* n = sfpts->at(i); 1861 // Remove safepoints
1827 assert(phase->get_loop(n) == this, ""); 1862 bool keep_one_sfpt = !(_has_call || _has_sfpt);
1828 if (phase->is_deleteable_safept(n)) { 1863 remove_safepoints(phase, keep_one_sfpt);
1829 phase->lazy_replace(n, n->in(TypeFunc::Control));
1830 }
1831 }
1832 }
1833 1864
1834 // Look for induction variables 1865 // Look for induction variables
1835 phase->replace_parallel_iv(this); 1866 phase->replace_parallel_iv(this);
1836 1867
1837 } else if (_parent != NULL && !_irreducible) { 1868 } else if (_parent != NULL && !_irreducible) {
1838 // Not a counted loop. 1869 // Not a counted loop. Keep one safepoint.
1839 // Look for a safepoint on the idom-path. 1870 bool keep_one_sfpt = true;
1840 Node* sfpt = tail(); 1871 remove_safepoints(phase, keep_one_sfpt);
1841 for (; sfpt != _head; sfpt = phase->idom(sfpt)) {
1842 if (sfpt->Opcode() == Op_SafePoint && phase->get_loop(sfpt) == this)
1843 break; // Found one
1844 }
1845 // Delete other safepoints in this loop.
1846 Node_List* sfpts = _safepts;
1847 if (sfpts != NULL && sfpt != _head && sfpt->Opcode() == Op_SafePoint) {
1848 for (uint i = 0; i < sfpts->size(); i++) {
1849 Node* n = sfpts->at(i);
1850 assert(phase->get_loop(n) == this, "");
1851 if (n != sfpt && phase->is_deleteable_safept(n)) {
1852 phase->lazy_replace(n, n->in(TypeFunc::Control));
1853 }
1854 }
1855 }
1856 } 1872 }
1857 1873
1858 // Recursively 1874 // Recursively
1859 if (_child) _child->counted_loop( phase ); 1875 if (_child) _child->counted_loop( phase );
1860 if (_next) _next ->counted_loop( phase ); 1876 if (_next) _next ->counted_loop( phase );
1904 1920
1905 if (cl->is_pre_loop ()) tty->print(" pre" ); 1921 if (cl->is_pre_loop ()) tty->print(" pre" );
1906 if (cl->is_main_loop()) tty->print(" main"); 1922 if (cl->is_main_loop()) tty->print(" main");
1907 if (cl->is_post_loop()) tty->print(" post"); 1923 if (cl->is_post_loop()) tty->print(" post");
1908 } 1924 }
1925 if (_has_call) tty->print(" has_call");
1926 if (_has_sfpt) tty->print(" has_sfpt");
1927 if (_rce_candidate) tty->print(" rce");
1928 if (_safepts != NULL && _safepts->size() > 0) {
1929 tty->print(" sfpts={"); _safepts->dump_simple(); tty->print(" }");
1930 }
1931 if (_required_safept != NULL && _required_safept->size() > 0) {
1932 tty->print(" req={"); _required_safept->dump_simple(); tty->print(" }");
1933 }
1909 tty->cr(); 1934 tty->cr();
1910 } 1935 }
1911 1936
1912 //------------------------------dump------------------------------------------- 1937 //------------------------------dump-------------------------------------------
1913 // Dump loops by loop tree 1938 // Dump loops by loop tree
2228 // node. For CFG nodes, the _nodes array starts out and remains 2253 // node. For CFG nodes, the _nodes array starts out and remains
2229 // holding the associated IdealLoopTree pointer. For DATA nodes, the 2254 // holding the associated IdealLoopTree pointer. For DATA nodes, the
2230 // _nodes array holds the earliest legal controlling CFG node. 2255 // _nodes array holds the earliest legal controlling CFG node.
2231 2256
2232 // Allocate stack with enough space to avoid frequent realloc 2257 // Allocate stack with enough space to avoid frequent realloc
2233 int stack_size = (C->unique() >> 1) + 16; // (unique>>1)+16 from Java2D stats 2258 int stack_size = (C->live_nodes() >> 1) + 16; // (live_nodes>>1)+16 from Java2D stats
2234 Node_Stack nstack( a, stack_size ); 2259 Node_Stack nstack( a, stack_size );
2235 2260
2236 visited.Clear(); 2261 visited.Clear();
2237 Node_List worklist(a); 2262 Node_List worklist(a);
2238 // Don't need C->root() on worklist since 2263 // Don't need C->root() on worklist since
2301 _ltree_root->dump(); 2326 _ltree_root->dump();
2302 } 2327 }
2303 #endif 2328 #endif
2304 2329
2305 if (skip_loop_opts) { 2330 if (skip_loop_opts) {
2331 // restore major progress flag
2332 for (int i = 0; i < old_progress; i++) {
2333 C->set_major_progress();
2334 }
2335
2306 // Cleanup any modified bits 2336 // Cleanup any modified bits
2307 _igvn.optimize(); 2337 _igvn.optimize();
2308 2338
2309 if (C->log() != NULL) { 2339 if (C->log() != NULL) {
2310 log_loop_tree(_ltree_root, _ltree_root, C->log()); 2340 log_loop_tree(_ltree_root, _ltree_root, C->log());
2684 if (_dom_depth[i] > 0 && _idom[i] != NULL) { 2714 if (_dom_depth[i] > 0 && _idom[i] != NULL) {
2685 _dom_depth[i] = no_depth_marker; 2715 _dom_depth[i] = no_depth_marker;
2686 } 2716 }
2687 } 2717 }
2688 if (_dom_stk == NULL) { 2718 if (_dom_stk == NULL) {
2689 uint init_size = C->unique() / 100; // Guess that 1/100 is a reasonable initial size. 2719 uint init_size = C->live_nodes() / 100; // Guess that 1/100 is a reasonable initial size.
2690 if (init_size < 10) init_size = 10; 2720 if (init_size < 10) init_size = 10;
2691 _dom_stk = new GrowableArray<uint>(init_size); 2721 _dom_stk = new GrowableArray<uint>(init_size);
2692 } 2722 }
2693 // Compute new depth for each node. 2723 // Compute new depth for each node.
2694 for (i = 0; i < _idom_size; i++) { 2724 for (i = 0; i < _idom_size; i++) {
2774 // I need to inspect loop header pre-order numbers to properly nest my 2804 // I need to inspect loop header pre-order numbers to properly nest my
2775 // loops. This means I need to sort my childrens' loops by pre-order. 2805 // loops. This means I need to sort my childrens' loops by pre-order.
2776 // The sort is of size number-of-control-children, which generally limits 2806 // The sort is of size number-of-control-children, which generally limits
2777 // it to size 2 (i.e., I just choose between my 2 target loops). 2807 // it to size 2 (i.e., I just choose between my 2 target loops).
2778 void PhaseIdealLoop::build_loop_tree() { 2808 void PhaseIdealLoop::build_loop_tree() {
2779 // Allocate stack of size C->unique()/2 to avoid frequent realloc 2809 // Allocate stack of size C->live_nodes()/2 to avoid frequent realloc
2780 GrowableArray <Node *> bltstack(C->unique() >> 1); 2810 GrowableArray <Node *> bltstack(C->live_nodes() >> 1);
2781 Node *n = C->root(); 2811 Node *n = C->root();
2782 bltstack.push(n); 2812 bltstack.push(n);
2783 int pre_order = 1; 2813 int pre_order = 1;
2784 int stack_size; 2814 int stack_size;
2785 2815
3664 #ifndef PRODUCT 3694 #ifndef PRODUCT
3665 //------------------------------dump------------------------------------------- 3695 //------------------------------dump-------------------------------------------
3666 void PhaseIdealLoop::dump( ) const { 3696 void PhaseIdealLoop::dump( ) const {
3667 ResourceMark rm; 3697 ResourceMark rm;
3668 Arena* arena = Thread::current()->resource_area(); 3698 Arena* arena = Thread::current()->resource_area();
3669 Node_Stack stack(arena, C->unique() >> 2); 3699 Node_Stack stack(arena, C->live_nodes() >> 2);
3670 Node_List rpo_list; 3700 Node_List rpo_list;
3671 VectorSet visited(arena); 3701 VectorSet visited(arena);
3672 visited.set(C->top()->_idx); 3702 visited.set(C->top()->_idx);
3673 rpo( C->root(), stack, visited, rpo_list ); 3703 rpo( C->root(), stack, visited, rpo_list );
3674 // Dump root loop indexed by last element in PO order 3704 // Dump root loop indexed by last element in PO order