< prev index next >

src/hotspot/share/opto/loopnode.cpp

Print this page




1377         Node* last = u;
1378         for(;;) {
1379           Node* next = NULL;
1380           for (DUIterator_Fast jmax, j = last->fast_outs(jmax); j < jmax; j++) {
1381             Node* uu = last->fast_out(j);
1382             if (uu->is_Store() && uu->in(0) == cle_out) {
1383               assert(next == NULL, "only one in the outer loop");
1384               next = uu;
1385             }
1386           }
1387           if (next == NULL) {
1388             break;
1389           }
1390           last = next;
1391         }
1392         Node* phi = NULL;
1393         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
1394           Node* uu = fast_out(j);
1395           if (uu->is_Phi()) {
1396             Node* be = uu->in(LoopNode::LoopBackControl);
1397             while (be->is_Store() && old_new[be->_idx] != NULL) {
1398               ShouldNotReachHere();
1399               be = be->in(MemNode::Memory);





1400             }
1401             if (be == last || be == first->in(MemNode::Memory)) {
1402               assert(phi == NULL, "only one phi");
1403               phi = uu;
1404             }
1405           }
1406         }
1407 #ifdef ASSERT
1408         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
1409           Node* uu = fast_out(j);
1410           if (uu->is_Phi() && uu->bottom_type() == Type::MEMORY) {
1411             if (uu->adr_type() == igvn->C->get_adr_type(igvn->C->get_alias_index(u->adr_type()))) {
1412               assert(phi == uu, "what's that phi?");
1413             } else if (uu->adr_type() == TypePtr::BOTTOM) {
1414               Node* n = uu->in(LoopNode::LoopBackControl);
1415               uint limit = igvn->C->live_nodes();
1416               uint i = 0;
1417               while (n != uu) {
1418                 i++;
1419                 assert(i < limit, "infinite loop");


1432                   ShouldNotReachHere();
1433                 }
1434               }
1435             }
1436           }
1437         }
1438 #endif
1439         if (phi == NULL) {
1440           // If the an entire chains was sunk, the
1441           // inner loop has no phi for that memory
1442           // slice, create one for the outer loop
1443           phi = PhiNode::make(this, first->in(MemNode::Memory), Type::MEMORY,
1444                               igvn->C->get_adr_type(igvn->C->get_alias_index(u->adr_type())));
1445           phi->set_req(LoopNode::LoopBackControl, last);
1446           phi = igvn->transform(phi);
1447           igvn->replace_input_of(first, MemNode::Memory, phi);
1448         } else {
1449           // Or fix the outer loop fix to include
1450           // that chain of stores.
1451           Node* be = phi->in(LoopNode::LoopBackControl);
1452           while (be->is_Store() && old_new[be->_idx] != NULL) {
1453             ShouldNotReachHere();
1454             be = be->in(MemNode::Memory);
1455           }
1456           if (be == first->in(MemNode::Memory)) {
1457             if (be == phi->in(LoopNode::LoopBackControl)) {
1458               igvn->replace_input_of(phi, LoopNode::LoopBackControl, last);
1459             } else {
1460               igvn->replace_input_of(be, MemNode::Memory, last);
1461             }
1462           } else {
1463 #ifdef ASSERT
1464             if (be == phi->in(LoopNode::LoopBackControl)) {
1465               assert(phi->in(LoopNode::LoopBackControl) == last, "");
1466             } else {
1467               assert(be->in(MemNode::Memory) == last, "");
1468             }
1469 #endif
1470           }
1471         }
1472       }
1473     }
1474   }
1475 




1377         Node* last = u;
1378         for(;;) {
1379           Node* next = NULL;
1380           for (DUIterator_Fast jmax, j = last->fast_outs(jmax); j < jmax; j++) {
1381             Node* uu = last->fast_out(j);
1382             if (uu->is_Store() && uu->in(0) == cle_out) {
1383               assert(next == NULL, "only one in the outer loop");
1384               next = uu;
1385             }
1386           }
1387           if (next == NULL) {
1388             break;
1389           }
1390           last = next;
1391         }
1392         Node* phi = NULL;
1393         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
1394           Node* uu = fast_out(j);
1395           if (uu->is_Phi()) {
1396             Node* be = uu->in(LoopNode::LoopBackControl);
1397             if (be->is_Store() && old_new[be->_idx] != NULL) {
1398               assert(false, "store on the backedge + sunk stores: unsupported");
1399               // drop outer loop
1400               IfNode* outer_le = outer_loop_end();
1401               Node* iff = igvn->transform(new IfNode(outer_le->in(0), outer_le->in(1), outer_le->_prob, outer_le->_fcnt));
1402               igvn->replace_node(outer_le, iff);
1403               inner_cl->clear_strip_mined();
1404               return;
1405             }
1406             if (be == last || be == first->in(MemNode::Memory)) {
1407               assert(phi == NULL, "only one phi");
1408               phi = uu;
1409             }
1410           }
1411         }
1412 #ifdef ASSERT
1413         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
1414           Node* uu = fast_out(j);
1415           if (uu->is_Phi() && uu->bottom_type() == Type::MEMORY) {
1416             if (uu->adr_type() == igvn->C->get_adr_type(igvn->C->get_alias_index(u->adr_type()))) {
1417               assert(phi == uu, "what's that phi?");
1418             } else if (uu->adr_type() == TypePtr::BOTTOM) {
1419               Node* n = uu->in(LoopNode::LoopBackControl);
1420               uint limit = igvn->C->live_nodes();
1421               uint i = 0;
1422               while (n != uu) {
1423                 i++;
1424                 assert(i < limit, "infinite loop");


1437                   ShouldNotReachHere();
1438                 }
1439               }
1440             }
1441           }
1442         }
1443 #endif
1444         if (phi == NULL) {
1445           // If the an entire chains was sunk, the
1446           // inner loop has no phi for that memory
1447           // slice, create one for the outer loop
1448           phi = PhiNode::make(this, first->in(MemNode::Memory), Type::MEMORY,
1449                               igvn->C->get_adr_type(igvn->C->get_alias_index(u->adr_type())));
1450           phi->set_req(LoopNode::LoopBackControl, last);
1451           phi = igvn->transform(phi);
1452           igvn->replace_input_of(first, MemNode::Memory, phi);
1453         } else {
1454           // Or fix the outer loop fix to include
1455           // that chain of stores.
1456           Node* be = phi->in(LoopNode::LoopBackControl);
1457           assert(!(be->is_Store() && old_new[be->_idx] != NULL), "store on the backedge + sunk stores: unsupported");



1458           if (be == first->in(MemNode::Memory)) {
1459             if (be == phi->in(LoopNode::LoopBackControl)) {
1460               igvn->replace_input_of(phi, LoopNode::LoopBackControl, last);
1461             } else {
1462               igvn->replace_input_of(be, MemNode::Memory, last);
1463             }
1464           } else {
1465 #ifdef ASSERT
1466             if (be == phi->in(LoopNode::LoopBackControl)) {
1467               assert(phi->in(LoopNode::LoopBackControl) == last, "");
1468             } else {
1469               assert(be->in(MemNode::Memory) == last, "");
1470             }
1471 #endif
1472           }
1473         }
1474       }
1475     }
1476   }
1477 


< prev index next >