提交 0aa6b0b4 编写于 作者: K kvn

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
上级 1c7034d7
...@@ -527,6 +527,7 @@ uint PhaseChaitin::Split( uint maxlrg ) { ...@@ -527,6 +527,7 @@ uint PhaseChaitin::Split( uint maxlrg ) {
// Initialize needs_phi and needs_split // Initialize needs_phi and needs_split
bool needs_phi = false; bool needs_phi = false;
bool needs_split = false; bool needs_split = false;
bool has_phi = false;
// Walk the predecessor blocks to check inputs for that live range // Walk the predecessor blocks to check inputs for that live range
// Grab predecessor block header // Grab predecessor block header
n1 = b->pred(1); n1 = b->pred(1);
...@@ -570,28 +571,30 @@ uint PhaseChaitin::Split( uint maxlrg ) { ...@@ -570,28 +571,30 @@ uint PhaseChaitin::Split( uint maxlrg ) {
} }
} // End for all potential Phi inputs } // End for all potential Phi inputs
// If a phi is needed, check for it // check block for appropriate phinode & update edges
if( needs_phi ) { for( insidx = 1; insidx <= b->end_idx(); insidx++ ) {
// check block for appropriate phinode & update edges n1 = b->_nodes[insidx];
for( insidx = 1; insidx <= b->end_idx(); insidx++ ) { // bail if this is not a phi
n1 = b->_nodes[insidx]; phi = n1->is_Phi() ? n1->as_Phi() : NULL;
// bail if this is not a phi if( phi == NULL ) {
phi = n1->is_Phi() ? n1->as_Phi() : NULL; // Keep track of index of first non-PhiNode instruction in block
if( phi == NULL ) { non_phi = insidx;
// Keep track of index of first non-PhiNode instruction in block // break out of the for loop as we have handled all phi nodes
non_phi = insidx; break;
// 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) ) {
// must be looking at a phi // found the necessary phi
if( Find_id(n1) == lidxs.at(slidx) ) { needs_phi = false;
// found the necessary phi has_phi = true;
needs_phi = false; // initialize the Reaches entry for this LRG
// initialize the Reaches entry for this LRG Reachblock[slidx] = phi;
Reachblock[slidx] = phi; break;
break; } // end if found correct phi
} // end if found correct phi } // end for all phi's
} // 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 // add new phinode if one not already found
if( needs_phi ) { if( needs_phi ) {
// create a new phi node and insert it into the block // create a new phi node and insert it into the block
...@@ -695,7 +698,8 @@ uint PhaseChaitin::Split( uint maxlrg ) { ...@@ -695,7 +698,8 @@ uint PhaseChaitin::Split( uint maxlrg ) {
} }
} }
assert( u, "at least 1 valid input expected" ); 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->replace_by(u); // Then replace with unique input
n->disconnect_inputs(NULL); n->disconnect_inputs(NULL);
b->_nodes.remove(insidx); b->_nodes.remove(insidx);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册