src/hotspot/share/opto/phaseX.cpp
changeset 52429 b64514ff68fd
parent 52224 4f2215a00ed1
child 52654 95ce45e0249f
equal deleted inserted replaced
52428:0e8084c8cbb7 52429:b64514ff68fd
   767 }
   767 }
   768 
   768 
   769 
   769 
   770 
   770 
   771 //=============================================================================
   771 //=============================================================================
       
   772 Node* PhaseGVN::apply_ideal(Node* k, bool can_reshape) {
       
   773   Node* i = BarrierSet::barrier_set()->barrier_set_c2()->ideal_node(this, k, can_reshape);
       
   774   if (i == NULL) {
       
   775     i = k->Ideal(this, can_reshape);
       
   776   }
       
   777   return i;
       
   778 }
       
   779 
       
   780 Node* PhaseGVN::apply_identity(Node* k) {
       
   781   Node* i = BarrierSet::barrier_set()->barrier_set_c2()->identity_node(this, k);
       
   782   if (i == k) {
       
   783     i = k->Identity(this);
       
   784   }
       
   785   return i;
       
   786 }
       
   787 
   772 //------------------------------transform--------------------------------------
   788 //------------------------------transform--------------------------------------
   773 // Return a node which computes the same function as this node, but in a
   789 // Return a node which computes the same function as this node, but in a
   774 // faster or cheaper fashion.
   790 // faster or cheaper fashion.
   775 Node *PhaseGVN::transform( Node *n ) {
   791 Node *PhaseGVN::transform( Node *n ) {
   776   return transform_no_reclaim(n);
   792   return transform_no_reclaim(n);
   784 
   800 
   785   // Apply the Ideal call in a loop until it no longer applies
   801   // Apply the Ideal call in a loop until it no longer applies
   786   Node *k = n;
   802   Node *k = n;
   787   NOT_PRODUCT( uint loop_count = 0; )
   803   NOT_PRODUCT( uint loop_count = 0; )
   788   while( 1 ) {
   804   while( 1 ) {
   789     Node *i = k->Ideal(this, /*can_reshape=*/false);
   805     Node *i = apply_ideal(k, /*can_reshape=*/false);
   790     if( !i ) break;
   806     if( !i ) break;
   791     assert( i->_idx >= k->_idx, "Idealize should return new nodes, use Identity to return old nodes" );
   807     assert( i->_idx >= k->_idx, "Idealize should return new nodes, use Identity to return old nodes" );
   792     k = i;
   808     k = i;
   793     assert(loop_count++ < K, "infinite loop in PhaseGVN::transform");
   809     assert(loop_count++ < K, "infinite loop in PhaseGVN::transform");
   794   }
   810   }
   821     NOT_PRODUCT( set_progress(); )
   837     NOT_PRODUCT( set_progress(); )
   822     return makecon(t);          // Turn into a constant
   838     return makecon(t);          // Turn into a constant
   823   }
   839   }
   824 
   840 
   825   // Now check for Identities
   841   // Now check for Identities
   826   Node *i = k->Identity(this);  // Look for a nearby replacement
   842   Node *i = apply_identity(k);  // Look for a nearby replacement
   827   if( i != k ) {                // Found? Return replacement!
   843   if( i != k ) {                // Found? Return replacement!
   828     NOT_PRODUCT( set_progress(); )
   844     NOT_PRODUCT( set_progress(); )
   829     return i;
   845     return i;
   830   }
   846   }
   831 
   847 
  1211   // Apply the Ideal call in a loop until it no longer applies
  1227   // Apply the Ideal call in a loop until it no longer applies
  1212   Node* k = n;
  1228   Node* k = n;
  1213   DEBUG_ONLY(dead_loop_check(k);)
  1229   DEBUG_ONLY(dead_loop_check(k);)
  1214   DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
  1230   DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
  1215   C->remove_modified_node(k);
  1231   C->remove_modified_node(k);
  1216   Node* i = k->Ideal(this, /*can_reshape=*/true);
  1232   Node* i = apply_ideal(k, /*can_reshape=*/true);
  1217   assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
  1233   assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
  1218 #ifndef PRODUCT
  1234 #ifndef PRODUCT
  1219   verify_step(k);
  1235   verify_step(k);
  1220   if (i && VerifyOpto ) {
  1236   if (i && VerifyOpto ) {
  1221     if (!allow_progress()) {
  1237     if (!allow_progress()) {
  1253     }
  1269     }
  1254     DEBUG_ONLY(dead_loop_check(k);)
  1270     DEBUG_ONLY(dead_loop_check(k);)
  1255     // Try idealizing again
  1271     // Try idealizing again
  1256     DEBUG_ONLY(is_new = (k->outcnt() == 0);)
  1272     DEBUG_ONLY(is_new = (k->outcnt() == 0);)
  1257     C->remove_modified_node(k);
  1273     C->remove_modified_node(k);
  1258     i = k->Ideal(this, /*can_reshape=*/true);
  1274     i = apply_ideal(k, /*can_reshape=*/true);
  1259     assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
  1275     assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
  1260 #ifndef PRODUCT
  1276 #ifndef PRODUCT
  1261     verify_step(k);
  1277     verify_step(k);
  1262     if (i && VerifyOpto) {
  1278     if (i && VerifyOpto) {
  1263       set_progress();
  1279       set_progress();
  1295     subsume_node(k, con);       // Everybody using k now uses con
  1311     subsume_node(k, con);       // Everybody using k now uses con
  1296     return con;
  1312     return con;
  1297   }
  1313   }
  1298 
  1314 
  1299   // Now check for Identities
  1315   // Now check for Identities
  1300   i = k->Identity(this);      // Look for a nearby replacement
  1316   i = apply_identity(k);      // Look for a nearby replacement
  1301   if (i != k) {                // Found? Return replacement!
  1317   if (i != k) {                // Found? Return replacement!
  1302     NOT_PRODUCT(set_progress();)
  1318     NOT_PRODUCT(set_progress();)
  1303     add_users_to_worklist(k);
  1319     add_users_to_worklist(k);
  1304     subsume_node(k, i);       // Everybody using k now uses i
  1320     subsume_node(k, i);       // Everybody using k now uses i
  1305     return i;
  1321     return i;