6746892: Register Allocator does not process a data phi with one unique input correctly
authorkvn
Wed, 10 Sep 2008 14:29:32 -0700
changeset 1134 799dce8f3426
parent 1126 2ec4685584f3
child 1135 9487203e5789
6746892: Register Allocator does not process a data phi with one unique input correctly Summary: Always look for the existing phi for a processed live_range. Reviewed-by: rasbold
hotspot/src/share/vm/opto/reg_split.cpp
--- a/hotspot/src/share/vm/opto/reg_split.cpp	Wed Sep 10 06:15:02 2008 -0700
+++ b/hotspot/src/share/vm/opto/reg_split.cpp	Wed Sep 10 14:29:32 2008 -0700
@@ -527,6 +527,7 @@
       // Initialize needs_phi and needs_split
       bool needs_phi = false;
       bool needs_split = false;
+      bool has_phi = false;
       // Walk the predecessor blocks to check inputs for that live range
       // Grab predecessor block header
       n1 = b->pred(1);
@@ -570,28 +571,30 @@
         }
       }  // End for all potential Phi inputs
 
-      // If a phi is needed, check for it
-      if( needs_phi ) {
-        // check block for appropriate phinode & update edges
-        for( insidx = 1; insidx <= b->end_idx(); insidx++ ) {
-          n1 = b->_nodes[insidx];
-          // bail if this is not a phi
-          phi = n1->is_Phi() ? n1->as_Phi() : NULL;
-          if( phi == NULL ) {
-            // Keep track of index of first non-PhiNode instruction in block
-            non_phi = insidx;
-            // break out of the for loop as we have handled all phi nodes
-            break;
-          }
-          // must be looking at a phi
-          if( Find_id(n1) == lidxs.at(slidx) ) {
-            // found the necessary phi
-            needs_phi = false;
-            // initialize the Reaches entry for this LRG
-            Reachblock[slidx] = phi;
-            break;
-          }  // end if found correct phi
-        }  // end for all phi's
+      // check block for appropriate phinode & update edges
+      for( insidx = 1; insidx <= b->end_idx(); insidx++ ) {
+        n1 = b->_nodes[insidx];
+        // bail if this is not a phi
+        phi = n1->is_Phi() ? n1->as_Phi() : NULL;
+        if( phi == NULL ) {
+          // Keep track of index of first non-PhiNode instruction in block
+          non_phi = insidx;
+          // break out of the for loop as we have handled all phi nodes
+          break;
+        }
+        // must be looking at a phi
+        if( Find_id(n1) == lidxs.at(slidx) ) {
+          // found the necessary phi
+          needs_phi = false;
+          has_phi = true;
+          // initialize the Reaches entry for this LRG
+          Reachblock[slidx] = phi;
+          break;
+        }  // end if found correct phi
+      }  // end for all phi's
+
+      // If a phi is needed or exist, check for it
+      if( needs_phi || has_phi ) {
         // add new phinode if one not already found
         if( needs_phi ) {
           // create a new phi node and insert it into the block
@@ -695,7 +698,8 @@
               }
             }
             assert( u, "at least 1 valid input expected" );
-            if( i >= cnt ) {    // Didn't find 2+ unique inputs?
+            if( i >= cnt ) {    // Found one unique input
+              assert(Find_id(n) == Find_id(u), "should be the same lrg");
               n->replace_by(u); // Then replace with unique input
               n->disconnect_inputs(NULL);
               b->_nodes.remove(insidx);