hotspot/src/share/vm/opto/loopTransform.cpp
changeset 30211 442fbbb31f75
parent 29344 49ad0989c84f
child 30593 69f942690128
equal deleted inserted replaced
30210:507826ef56fd 30211:442fbbb31f75
    36 #include "opto/movenode.hpp"
    36 #include "opto/movenode.hpp"
    37 #include "opto/opaquenode.hpp"
    37 #include "opto/opaquenode.hpp"
    38 #include "opto/rootnode.hpp"
    38 #include "opto/rootnode.hpp"
    39 #include "opto/runtime.hpp"
    39 #include "opto/runtime.hpp"
    40 #include "opto/subnode.hpp"
    40 #include "opto/subnode.hpp"
       
    41 #include "opto/vectornode.hpp"
    41 
    42 
    42 //------------------------------is_loop_exit-----------------------------------
    43 //------------------------------is_loop_exit-----------------------------------
    43 // Given an IfNode, return the loop-exiting projection or NULL if both
    44 // Given an IfNode, return the loop-exiting projection or NULL if both
    44 // arms remain in the loop.
    45 // arms remain in the loop.
    45 Node *IdealLoopTree::is_loop_exit(Node *iff) const {
    46 Node *IdealLoopTree::is_loop_exit(Node *iff) const {
  1522     assert((cl->trip_count() & 1) == 0, "missed peeling");
  1523     assert((cl->trip_count() & 1) == 0, "missed peeling");
  1523     do_unroll(loop, old_new, false);
  1524     do_unroll(loop, old_new, false);
  1524   }
  1525   }
  1525 }
  1526 }
  1526 
  1527 
       
  1528 void PhaseIdealLoop::mark_reductions(IdealLoopTree *loop) {
       
  1529   if (SuperWordReductions == false) return;
       
  1530 
       
  1531   CountedLoopNode* loop_head = loop->_head->as_CountedLoop();
       
  1532   if (loop_head->unrolled_count() > 1) {
       
  1533     return;
       
  1534   }
       
  1535 
       
  1536   Node* trip_phi = loop_head->phi();
       
  1537   for (DUIterator_Fast imax, i = loop_head->fast_outs(imax); i < imax; i++) {
       
  1538     Node* phi = loop_head->fast_out(i);
       
  1539     if (phi->is_Phi() && phi->outcnt() > 0 && phi != trip_phi) {
       
  1540       // For definitions which are loop inclusive and not tripcounts.
       
  1541       Node* def_node = phi->in(LoopNode::LoopBackControl);
       
  1542 
       
  1543       if (def_node != NULL) {
       
  1544         Node* n_ctrl = get_ctrl(def_node);
       
  1545         if (n_ctrl != NULL && loop->is_member(get_loop(n_ctrl))) {
       
  1546           // Now test it to see if it fits the standard pattern for a reduction operator.
       
  1547           int opc = def_node->Opcode();
       
  1548           if (opc != ReductionNode::opcode(opc, def_node->bottom_type()->basic_type())) {
       
  1549             if (!def_node->is_reduction()) { // Not marked yet
       
  1550               // To be a reduction, the arithmetic node must have the phi as input and provide a def to it
       
  1551               for (unsigned j = 1; j < def_node->req(); j++) {
       
  1552                 Node* in = def_node->in(j);
       
  1553                 if (in == phi) {
       
  1554                   def_node->add_flag(Node::Flag_is_reduction);
       
  1555                   break;
       
  1556                 }
       
  1557               }
       
  1558             }
       
  1559           }
       
  1560         }
       
  1561       }
       
  1562     }
       
  1563   }
       
  1564 }
       
  1565 
  1527 //------------------------------dominates_backedge---------------------------------
  1566 //------------------------------dominates_backedge---------------------------------
  1528 // Returns true if ctrl is executed on every complete iteration
  1567 // Returns true if ctrl is executed on every complete iteration
  1529 bool IdealLoopTree::dominates_backedge(Node* ctrl) {
  1568 bool IdealLoopTree::dominates_backedge(Node* ctrl) {
  1530   assert(ctrl->is_CFG(), "must be control");
  1569   assert(ctrl->is_CFG(), "must be control");
  1531   Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
  1570   Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
  2359     // Double loop body for unrolling.  Adjust the minimum-trip test (will do
  2398     // Double loop body for unrolling.  Adjust the minimum-trip test (will do
  2360     // twice as many iterations as before) and the main body limit (only do
  2399     // twice as many iterations as before) and the main body limit (only do
  2361     // an even number of trips).  If we are peeling, we might enable some RCE
  2400     // an even number of trips).  If we are peeling, we might enable some RCE
  2362     // and we'd rather unroll the post-RCE'd loop SO... do not unroll if
  2401     // and we'd rather unroll the post-RCE'd loop SO... do not unroll if
  2363     // peeling.
  2402     // peeling.
  2364     if (should_unroll && !should_peel)
  2403     if (should_unroll && !should_peel) {
  2365       phase->do_unroll(this,old_new, true);
  2404       phase->mark_reductions(this);
       
  2405       phase->do_unroll(this, old_new, true);
       
  2406     }
  2366 
  2407 
  2367     // Adjust the pre-loop limits to align the main body
  2408     // Adjust the pre-loop limits to align the main body
  2368     // iterations.
  2409     // iterations.
  2369     if (should_align)
  2410     if (should_align)
  2370       Unimplemented();
  2411       Unimplemented();