loopTransform.cpp (2230:9dc311b8473e) | loopTransform.cpp (2250:1927db75dd85) |
---|---|
1/* 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * --- 1594 unchanged lines hidden (view full) --- 1603 1604 if (!_head->is_CountedLoop()) 1605 return false; // Dead loop 1606 CountedLoopNode *cl = _head->as_CountedLoop(); 1607 if (!cl->loopexit()) 1608 return false; // Malformed loop 1609 if (!phase->is_member(this, phase->get_ctrl(cl->loopexit()->in(CountedLoopEndNode::TestValue)))) 1610 return false; // Infinite loop | 1/* 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * --- 1594 unchanged lines hidden (view full) --- 1603 1604 if (!_head->is_CountedLoop()) 1605 return false; // Dead loop 1606 CountedLoopNode *cl = _head->as_CountedLoop(); 1607 if (!cl->loopexit()) 1608 return false; // Malformed loop 1609 if (!phase->is_member(this, phase->get_ctrl(cl->loopexit()->in(CountedLoopEndNode::TestValue)))) 1610 return false; // Infinite loop |
1611#ifndef PRODUCT 1612 if (PrintOpto) { 1613 tty->print("Removing empty loop"); 1614 this->dump_head(); 1615 } else if (TraceLoopOpts) { 1616 tty->print("Empty "); 1617 this->dump_head(); 1618 } 1619#endif | 1611 |
1620#ifdef ASSERT 1621 // Ensure only one phi which is the iv. 1622 Node* iv = NULL; 1623 for (DUIterator_Fast imax, i = cl->fast_outs(imax); i < imax; i++) { 1624 Node* n = cl->fast_out(i); 1625 if (n->Opcode() == Op_Phi) { 1626 assert(iv == NULL, "Too many phis" ); 1627 iv = n; 1628 } 1629 } 1630 assert(iv == cl->phi(), "Wrong phi" ); 1631#endif | 1612#ifdef ASSERT 1613 // Ensure only one phi which is the iv. 1614 Node* iv = NULL; 1615 for (DUIterator_Fast imax, i = cl->fast_outs(imax); i < imax; i++) { 1616 Node* n = cl->fast_out(i); 1617 if (n->Opcode() == Op_Phi) { 1618 assert(iv == NULL, "Too many phis" ); 1619 iv = n; 1620 } 1621 } 1622 assert(iv == cl->phi(), "Wrong phi" ); 1623#endif |
1624 1625 // main and post loops have explicitly created zero trip guard 1626 bool needs_guard = !cl->is_main_loop() && !cl->is_post_loop(); 1627 if (needs_guard) { 1628 // Check for an obvious zero trip guard. 1629 Node* inctrl = cl->in(LoopNode::EntryControl); 1630 if (inctrl->Opcode() == Op_IfTrue) { 1631 // The test should look like just the backedge of a CountedLoop 1632 Node* iff = inctrl->in(0); 1633 if (iff->is_If()) { 1634 Node* bol = iff->in(1); 1635 if (bol->is_Bool() && bol->as_Bool()->_test._test == cl->loopexit()->test_trip()) { 1636 Node* cmp = bol->in(1); 1637 if (cmp->is_Cmp() && cmp->in(1) == cl->init_trip() && cmp->in(2) == cl->limit()) { 1638 needs_guard = false; 1639 } 1640 } 1641 } 1642 } 1643 } 1644 1645#ifndef PRODUCT 1646 if (PrintOpto) { 1647 tty->print("Removing empty loop with%s zero trip guard", needs_guard ? "out" : ""); 1648 this->dump_head(); 1649 } else if (TraceLoopOpts) { 1650 tty->print("Empty with%s zero trip guard ", needs_guard ? "out" : ""); 1651 this->dump_head(); 1652 } 1653#endif 1654 1655 if (needs_guard) { 1656 // Peel the loop to ensure there's a zero trip guard 1657 Node_List old_new; 1658 phase->do_peeling(this, old_new); 1659 } 1660 |
|
1632 // Replace the phi at loop head with the final value of the last 1633 // iteration. Then the CountedLoopEnd will collapse (backedge never 1634 // taken) and all loop-invariant uses of the exit values will be correct. 1635 Node *phi = cl->phi(); 1636 Node *final = new (phase->C, 3) SubINode( cl->limit(), cl->stride() ); 1637 phase->register_new_node(final,cl->in(LoopNode::EntryControl)); 1638 phase->_igvn.replace_node(phi,final); 1639 phase->C->set_major_progress(); --- 1178 unchanged lines hidden --- | 1661 // Replace the phi at loop head with the final value of the last 1662 // iteration. Then the CountedLoopEnd will collapse (backedge never 1663 // taken) and all loop-invariant uses of the exit values will be correct. 1664 Node *phi = cl->phi(); 1665 Node *final = new (phase->C, 3) SubINode( cl->limit(), cl->stride() ); 1666 phase->register_new_node(final,cl->in(LoopNode::EntryControl)); 1667 phase->_igvn.replace_node(phi,final); 1668 phase->C->set_major_progress(); --- 1178 unchanged lines hidden --- |