637 const Value l = x->x(); ValueType* lt = l->type(); |
637 const Value l = x->x(); ValueType* lt = l->type(); |
638 const Value r = x->y(); ValueType* rt = r->type(); |
638 const Value r = x->y(); ValueType* rt = r->type(); |
639 |
639 |
640 if (l == r && !lt->is_float_kind()) { |
640 if (l == r && !lt->is_float_kind()) { |
641 // pattern: If (a cond a) => simplify to Goto |
641 // pattern: If (a cond a) => simplify to Goto |
642 BlockBegin* sux; |
642 BlockBegin* sux = NULL; |
643 switch (x->cond()) { |
643 switch (x->cond()) { |
644 case If::eql: sux = x->sux_for(true); break; |
644 case If::eql: sux = x->sux_for(true); break; |
645 case If::neq: sux = x->sux_for(false); break; |
645 case If::neq: sux = x->sux_for(false); break; |
646 case If::lss: sux = x->sux_for(false); break; |
646 case If::lss: sux = x->sux_for(false); break; |
647 case If::leq: sux = x->sux_for(true); break; |
647 case If::leq: sux = x->sux_for(true); break; |
648 case If::gtr: sux = x->sux_for(false); break; |
648 case If::gtr: sux = x->sux_for(false); break; |
649 case If::geq: sux = x->sux_for(true); break; |
649 case If::geq: sux = x->sux_for(true); break; |
|
650 default: ShouldNotReachHere(); |
650 } |
651 } |
651 // If is a safepoint then the debug information should come from the state_before of the If. |
652 // If is a safepoint then the debug information should come from the state_before of the If. |
652 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); |
653 set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); |
653 return; |
654 return; |
654 } |
655 } |
682 // all successors identical => simplify to: Goto |
683 // all successors identical => simplify to: Goto |
683 set_canonical(new Goto(lss_sux, x->state_before(), x->is_safepoint())); |
684 set_canonical(new Goto(lss_sux, x->state_before(), x->is_safepoint())); |
684 } else { |
685 } else { |
685 // two successors differ and two successors are the same => simplify to: If (x cmp y) |
686 // two successors differ and two successors are the same => simplify to: If (x cmp y) |
686 // determine new condition & successors |
687 // determine new condition & successors |
687 If::Condition cond; |
688 If::Condition cond = If::eql; |
688 BlockBegin* tsux = NULL; |
689 BlockBegin* tsux = NULL; |
689 BlockBegin* fsux = NULL; |
690 BlockBegin* fsux = NULL; |
690 if (lss_sux == eql_sux) { cond = If::leq; tsux = lss_sux; fsux = gtr_sux; } |
691 if (lss_sux == eql_sux) { cond = If::leq; tsux = lss_sux; fsux = gtr_sux; } |
691 else if (lss_sux == gtr_sux) { cond = If::neq; tsux = lss_sux; fsux = eql_sux; } |
692 else if (lss_sux == gtr_sux) { cond = If::neq; tsux = lss_sux; fsux = eql_sux; } |
692 else if (eql_sux == gtr_sux) { cond = If::geq; tsux = eql_sux; fsux = lss_sux; } |
693 else if (eql_sux == gtr_sux) { cond = If::geq; tsux = eql_sux; fsux = lss_sux; } |