Mercurial > hg > truffle
comparison src/share/vm/opto/reg_split.cpp @ 330:1c6e3bfb543a
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
author | kvn |
---|---|
date | Wed, 10 Sep 2008 14:29:32 -0700 |
parents | ea18057223c4 |
children | 9ee9cf798b59 |
comparison
equal
deleted
inserted
replaced
322:f9847b70eccd | 330:1c6e3bfb543a |
---|---|
525 } | 525 } |
526 | 526 |
527 // Initialize needs_phi and needs_split | 527 // Initialize needs_phi and needs_split |
528 bool needs_phi = false; | 528 bool needs_phi = false; |
529 bool needs_split = false; | 529 bool needs_split = false; |
530 bool has_phi = false; | |
530 // Walk the predecessor blocks to check inputs for that live range | 531 // Walk the predecessor blocks to check inputs for that live range |
531 // Grab predecessor block header | 532 // Grab predecessor block header |
532 n1 = b->pred(1); | 533 n1 = b->pred(1); |
533 // Grab the appropriate reaching def info for inpidx | 534 // Grab the appropriate reaching def info for inpidx |
534 pred = _cfg._bbs[n1->_idx]; | 535 pred = _cfg._bbs[n1->_idx]; |
568 n3 = n2; | 569 n3 = n2; |
569 u3 = u2; | 570 u3 = u2; |
570 } | 571 } |
571 } // End for all potential Phi inputs | 572 } // End for all potential Phi inputs |
572 | 573 |
573 // If a phi is needed, check for it | 574 // check block for appropriate phinode & update edges |
574 if( needs_phi ) { | 575 for( insidx = 1; insidx <= b->end_idx(); insidx++ ) { |
575 // check block for appropriate phinode & update edges | 576 n1 = b->_nodes[insidx]; |
576 for( insidx = 1; insidx <= b->end_idx(); insidx++ ) { | 577 // bail if this is not a phi |
577 n1 = b->_nodes[insidx]; | 578 phi = n1->is_Phi() ? n1->as_Phi() : NULL; |
578 // bail if this is not a phi | 579 if( phi == NULL ) { |
579 phi = n1->is_Phi() ? n1->as_Phi() : NULL; | 580 // Keep track of index of first non-PhiNode instruction in block |
580 if( phi == NULL ) { | 581 non_phi = insidx; |
581 // Keep track of index of first non-PhiNode instruction in block | 582 // break out of the for loop as we have handled all phi nodes |
582 non_phi = insidx; | 583 break; |
583 // break out of the for loop as we have handled all phi nodes | 584 } |
584 break; | 585 // must be looking at a phi |
585 } | 586 if( Find_id(n1) == lidxs.at(slidx) ) { |
586 // must be looking at a phi | 587 // found the necessary phi |
587 if( Find_id(n1) == lidxs.at(slidx) ) { | 588 needs_phi = false; |
588 // found the necessary phi | 589 has_phi = true; |
589 needs_phi = false; | 590 // initialize the Reaches entry for this LRG |
590 // initialize the Reaches entry for this LRG | 591 Reachblock[slidx] = phi; |
591 Reachblock[slidx] = phi; | 592 break; |
592 break; | 593 } // end if found correct phi |
593 } // end if found correct phi | 594 } // end for all phi's |
594 } // end for all phi's | 595 |
596 // If a phi is needed or exist, check for it | |
597 if( needs_phi || has_phi ) { | |
595 // add new phinode if one not already found | 598 // add new phinode if one not already found |
596 if( needs_phi ) { | 599 if( needs_phi ) { |
597 // create a new phi node and insert it into the block | 600 // create a new phi node and insert it into the block |
598 // type is taken from left over pointer to a predecessor | 601 // type is taken from left over pointer to a predecessor |
599 assert(n3,"No non-NULL reaching DEF for a Phi"); | 602 assert(n3,"No non-NULL reaching DEF for a Phi"); |
693 break; | 696 break; |
694 u = n->in(i); // Else record it | 697 u = n->in(i); // Else record it |
695 } | 698 } |
696 } | 699 } |
697 assert( u, "at least 1 valid input expected" ); | 700 assert( u, "at least 1 valid input expected" ); |
698 if( i >= cnt ) { // Didn't find 2+ unique inputs? | 701 if( i >= cnt ) { // Found one unique input |
702 assert(Find_id(n) == Find_id(u), "should be the same lrg"); | |
699 n->replace_by(u); // Then replace with unique input | 703 n->replace_by(u); // Then replace with unique input |
700 n->disconnect_inputs(NULL); | 704 n->disconnect_inputs(NULL); |
701 b->_nodes.remove(insidx); | 705 b->_nodes.remove(insidx); |
702 insidx--; | 706 insidx--; |
703 b->_ihrp_index--; | 707 b->_ihrp_index--; |