1 /*
2 * Copyright (c) 1997, 2016, 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 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
503 if( max != outcnt() ) {
504 progress = true;
505 j = refresh_out_pos(j);
506 max = outcnt();
507 }
508 }
509 }
510 }
511 add_to_worklist = true;
512 i--;
513 }
514 }
515
516 if (can_reshape && cnt == 1) {
517 // Is it dead loop?
518 // If it is LoopNopde it had 2 (+1 itself) inputs and
519 // one of them was cut. The loop is dead if it was EntryContol.
520 // Loop node may have only one input because entry path
521 // is removed in PhaseIdealLoop::Dominators().
522 assert(!this->is_Loop() || cnt_orig <= 3, "Loop node should have 3 or less inputs");
523 if (this->is_Loop() && (del_it == LoopNode::EntryControl ||
524 del_it == 0 && is_unreachable_region(phase)) ||
525 !this->is_Loop() && has_phis && is_unreachable_region(phase)) {
526 // Yes, the region will be removed during the next step below.
527 // Cut the backedge input and remove phis since no data paths left.
528 // We don't cut outputs to other nodes here since we need to put them
529 // on the worklist.
530 PhaseIterGVN *igvn = phase->is_IterGVN();
531 if (in(1)->outcnt() == 1) {
532 igvn->_worklist.push(in(1));
533 }
534 del_req(1);
535 cnt = 0;
536 assert( req() == 1, "no more inputs expected" );
537 uint max = outcnt();
538 bool progress = true;
539 Node *top = phase->C->top();
540 DUIterator j;
541 while(progress) {
542 progress = false;
543 for (j = outs(); has_out(j); j++) {
544 Node *n = out(j);
545 if( n->is_Phi() ) {
1671 uin = unique_input(phase, true);
1672 }
1673 if (uin == top) { // Simplest case: no alive inputs.
1674 if (can_reshape) // IGVN transformation
1675 return top;
1676 else
1677 return NULL; // Identity will return TOP
1678 } else if (uin != NULL) {
1679 // Only one not-NULL unique input path is left.
1680 // Determine if this input is backedge of a loop.
1681 // (Skip new phis which have no uses and dead regions).
1682 if (outcnt() > 0 && r->in(0) != NULL) {
1683 // First, take the short cut when we know it is a loop and
1684 // the EntryControl data path is dead.
1685 // Loop node may have only one input because entry path
1686 // is removed in PhaseIdealLoop::Dominators().
1687 assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
1688 bool is_loop = (r->is_Loop() && r->req() == 3);
1689 // Then, check if there is a data loop when phi references itself directly
1690 // or through other data nodes.
1691 if (is_loop && !uin->eqv_uncast(in(LoopNode::EntryControl)) ||
1692 !is_loop && is_unsafe_data_reference(uin)) {
1693 // Break this data loop to avoid creation of a dead loop.
1694 if (can_reshape) {
1695 return top;
1696 } else {
1697 // We can't return top if we are in Parse phase - cut inputs only
1698 // let Identity to handle the case.
1699 replace_edge(uin, top);
1700 return NULL;
1701 }
1702 }
1703 }
1704
1705 if (uncasted) {
1706 // Add cast nodes between the phi to be removed and its unique input.
1707 // Wait until after parsing for the type information to propagate from the casts.
1708 assert(can_reshape, "Invalid during parsing");
1709 const Type* phi_type = bottom_type();
1710 assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
1711 // Add casts to carry the control dependency of the Phi that is
1712 // going away
|
1 /*
2 * Copyright (c) 1997, 2017, 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 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
503 if( max != outcnt() ) {
504 progress = true;
505 j = refresh_out_pos(j);
506 max = outcnt();
507 }
508 }
509 }
510 }
511 add_to_worklist = true;
512 i--;
513 }
514 }
515
516 if (can_reshape && cnt == 1) {
517 // Is it dead loop?
518 // If it is LoopNopde it had 2 (+1 itself) inputs and
519 // one of them was cut. The loop is dead if it was EntryContol.
520 // Loop node may have only one input because entry path
521 // is removed in PhaseIdealLoop::Dominators().
522 assert(!this->is_Loop() || cnt_orig <= 3, "Loop node should have 3 or less inputs");
523 if ((this->is_Loop() && (del_it == LoopNode::EntryControl ||
524 (del_it == 0 && is_unreachable_region(phase)))) ||
525 (!this->is_Loop() && has_phis && is_unreachable_region(phase))) {
526 // Yes, the region will be removed during the next step below.
527 // Cut the backedge input and remove phis since no data paths left.
528 // We don't cut outputs to other nodes here since we need to put them
529 // on the worklist.
530 PhaseIterGVN *igvn = phase->is_IterGVN();
531 if (in(1)->outcnt() == 1) {
532 igvn->_worklist.push(in(1));
533 }
534 del_req(1);
535 cnt = 0;
536 assert( req() == 1, "no more inputs expected" );
537 uint max = outcnt();
538 bool progress = true;
539 Node *top = phase->C->top();
540 DUIterator j;
541 while(progress) {
542 progress = false;
543 for (j = outs(); has_out(j); j++) {
544 Node *n = out(j);
545 if( n->is_Phi() ) {
1671 uin = unique_input(phase, true);
1672 }
1673 if (uin == top) { // Simplest case: no alive inputs.
1674 if (can_reshape) // IGVN transformation
1675 return top;
1676 else
1677 return NULL; // Identity will return TOP
1678 } else if (uin != NULL) {
1679 // Only one not-NULL unique input path is left.
1680 // Determine if this input is backedge of a loop.
1681 // (Skip new phis which have no uses and dead regions).
1682 if (outcnt() > 0 && r->in(0) != NULL) {
1683 // First, take the short cut when we know it is a loop and
1684 // the EntryControl data path is dead.
1685 // Loop node may have only one input because entry path
1686 // is removed in PhaseIdealLoop::Dominators().
1687 assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
1688 bool is_loop = (r->is_Loop() && r->req() == 3);
1689 // Then, check if there is a data loop when phi references itself directly
1690 // or through other data nodes.
1691 if ((is_loop && !uin->eqv_uncast(in(LoopNode::EntryControl))) ||
1692 (!is_loop && is_unsafe_data_reference(uin))) {
1693 // Break this data loop to avoid creation of a dead loop.
1694 if (can_reshape) {
1695 return top;
1696 } else {
1697 // We can't return top if we are in Parse phase - cut inputs only
1698 // let Identity to handle the case.
1699 replace_edge(uin, top);
1700 return NULL;
1701 }
1702 }
1703 }
1704
1705 if (uncasted) {
1706 // Add cast nodes between the phi to be removed and its unique input.
1707 // Wait until after parsing for the type information to propagate from the casts.
1708 assert(can_reshape, "Invalid during parsing");
1709 const Type* phi_type = bottom_type();
1710 assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
1711 // Add casts to carry the control dependency of the Phi that is
1712 // going away
|