656 //------------------------------fold_compares----------------------------
657 // See if a pair of CmpIs can be converted into a CmpU. In some cases
658 // the direction of this if is determined by the preceding if so it
659 // can be eliminate entirely. Given an if testing (CmpI n c) check
660 // for an immediately control dependent if that is testing (CmpI n c2)
661 // and has one projection leading to this if and the other projection
662 // leading to a region that merges one of this ifs control
663 // projections.
664 //
665 // If
666 // / |
667 // / |
668 // / |
669 // If |
670 // /\ |
671 // / \ |
672 // / \ |
673 // / Region
674 //
675 Node* IfNode::fold_compares(PhaseGVN* phase) {
676 if (!phase->C->eliminate_boxing() || Opcode() != Op_If) return NULL;
677
678 Node* this_cmp = in(1)->in(1);
679 if (this_cmp != NULL && this_cmp->Opcode() == Op_CmpI &&
680 this_cmp->in(2)->is_Con() && this_cmp->in(2) != phase->C->top()) {
681 Node* ctrl = in(0);
682 BoolNode* this_bool = in(1)->as_Bool();
683 Node* n = this_cmp->in(1);
684 int hi = this_cmp->in(2)->get_int();
685 if (ctrl != NULL && ctrl->is_Proj() && ctrl->outcnt() == 1 &&
686 ctrl->in(0)->is_If() &&
687 ctrl->in(0)->outcnt() == 2 &&
688 ctrl->in(0)->in(1)->is_Bool() &&
689 ctrl->in(0)->in(1)->in(1)->Opcode() == Op_CmpI &&
690 ctrl->in(0)->in(1)->in(1)->in(2)->is_Con() &&
691 ctrl->in(0)->in(1)->in(1)->in(2) != phase->C->top() &&
692 ctrl->in(0)->in(1)->in(1)->in(1) == n) {
693 IfNode* dom_iff = ctrl->in(0)->as_If();
694 Node* otherproj = dom_iff->proj_out(!ctrl->as_Proj()->_con);
695 if (otherproj->outcnt() == 1 && otherproj->unique_out()->is_Region() &&
696 this_bool->_test._test != BoolTest::ne && this_bool->_test._test != BoolTest::eq) {
|
656 //------------------------------fold_compares----------------------------
657 // See if a pair of CmpIs can be converted into a CmpU. In some cases
658 // the direction of this if is determined by the preceding if so it
659 // can be eliminate entirely. Given an if testing (CmpI n c) check
660 // for an immediately control dependent if that is testing (CmpI n c2)
661 // and has one projection leading to this if and the other projection
662 // leading to a region that merges one of this ifs control
663 // projections.
664 //
665 // If
666 // / |
667 // / |
668 // / |
669 // If |
670 // /\ |
671 // / \ |
672 // / \ |
673 // / Region
674 //
675 Node* IfNode::fold_compares(PhaseGVN* phase) {
676 if (Opcode() != Op_If) return NULL;
677
678 Node* this_cmp = in(1)->in(1);
679 if (this_cmp != NULL && this_cmp->Opcode() == Op_CmpI &&
680 this_cmp->in(2)->is_Con() && this_cmp->in(2) != phase->C->top()) {
681 Node* ctrl = in(0);
682 BoolNode* this_bool = in(1)->as_Bool();
683 Node* n = this_cmp->in(1);
684 int hi = this_cmp->in(2)->get_int();
685 if (ctrl != NULL && ctrl->is_Proj() && ctrl->outcnt() == 1 &&
686 ctrl->in(0)->is_If() &&
687 ctrl->in(0)->outcnt() == 2 &&
688 ctrl->in(0)->in(1)->is_Bool() &&
689 ctrl->in(0)->in(1)->in(1)->Opcode() == Op_CmpI &&
690 ctrl->in(0)->in(1)->in(1)->in(2)->is_Con() &&
691 ctrl->in(0)->in(1)->in(1)->in(2) != phase->C->top() &&
692 ctrl->in(0)->in(1)->in(1)->in(1) == n) {
693 IfNode* dom_iff = ctrl->in(0)->as_If();
694 Node* otherproj = dom_iff->proj_out(!ctrl->as_Proj()->_con);
695 if (otherproj->outcnt() == 1 && otherproj->unique_out()->is_Region() &&
696 this_bool->_test._test != BoolTest::ne && this_bool->_test._test != BoolTest::eq) {
|