src/share/vm/opto/loopPredicate.cpp

changeset 2868
2e038ad0c1d0
parent 2727
08eb13460b3a
child 2877
bad7ecd0b6ed
equal deleted inserted replaced
2867:49d67a090fe2 2868:2e038ad0c1d0
698 // max(scale*i + offset) = scale*init + offset 698 // max(scale*i + offset) = scale*init + offset
699 BoolNode* PhaseIdealLoop::rc_predicate(Node* ctrl, 699 BoolNode* PhaseIdealLoop::rc_predicate(Node* ctrl,
700 int scale, Node* offset, 700 int scale, Node* offset,
701 Node* init, Node* limit, Node* stride, 701 Node* init, Node* limit, Node* stride,
702 Node* range, bool upper) { 702 Node* range, bool upper) {
703 DEBUG_ONLY(ttyLocker ttyl); 703 stringStream* predString = NULL;
704 if (TraceLoopPredicate) tty->print("rc_predicate "); 704 if (TraceLoopPredicate) {
705 predString = new stringStream();
706 predString->print("rc_predicate ");
707 }
705 708
706 Node* max_idx_expr = init; 709 Node* max_idx_expr = init;
707 int stride_con = stride->get_int(); 710 int stride_con = stride->get_int();
708 if ((stride_con > 0) == (scale > 0) == upper) { 711 if ((stride_con > 0) == (scale > 0) == upper) {
709 max_idx_expr = new (C, 3) SubINode(limit, stride); 712 max_idx_expr = new (C, 3) SubINode(limit, stride);
710 register_new_node(max_idx_expr, ctrl); 713 register_new_node(max_idx_expr, ctrl);
711 if (TraceLoopPredicate) tty->print("(limit - stride) "); 714 if (TraceLoopPredicate) predString->print("(limit - stride) ");
712 } else { 715 } else {
713 if (TraceLoopPredicate) tty->print("init "); 716 if (TraceLoopPredicate) predString->print("init ");
714 } 717 }
715 718
716 if (scale != 1) { 719 if (scale != 1) {
717 ConNode* con_scale = _igvn.intcon(scale); 720 ConNode* con_scale = _igvn.intcon(scale);
718 max_idx_expr = new (C, 3) MulINode(max_idx_expr, con_scale); 721 max_idx_expr = new (C, 3) MulINode(max_idx_expr, con_scale);
719 register_new_node(max_idx_expr, ctrl); 722 register_new_node(max_idx_expr, ctrl);
720 if (TraceLoopPredicate) tty->print("* %d ", scale); 723 if (TraceLoopPredicate) predString->print("* %d ", scale);
721 } 724 }
722 725
723 if (offset && (!offset->is_Con() || offset->get_int() != 0)){ 726 if (offset && (!offset->is_Con() || offset->get_int() != 0)){
724 max_idx_expr = new (C, 3) AddINode(max_idx_expr, offset); 727 max_idx_expr = new (C, 3) AddINode(max_idx_expr, offset);
725 register_new_node(max_idx_expr, ctrl); 728 register_new_node(max_idx_expr, ctrl);
726 if (TraceLoopPredicate) 729 if (TraceLoopPredicate)
727 if (offset->is_Con()) tty->print("+ %d ", offset->get_int()); 730 if (offset->is_Con()) predString->print("+ %d ", offset->get_int());
728 else tty->print("+ offset "); 731 else predString->print("+ offset ");
729 } 732 }
730 733
731 CmpUNode* cmp = new (C, 3) CmpUNode(max_idx_expr, range); 734 CmpUNode* cmp = new (C, 3) CmpUNode(max_idx_expr, range);
732 register_new_node(cmp, ctrl); 735 register_new_node(cmp, ctrl);
733 BoolNode* bol = new (C, 2) BoolNode(cmp, BoolTest::lt); 736 BoolNode* bol = new (C, 2) BoolNode(cmp, BoolTest::lt);
734 register_new_node(bol, ctrl); 737 register_new_node(bol, ctrl);
735 738
736 if (TraceLoopPredicate) tty->print_cr("<u range"); 739 if (TraceLoopPredicate) {
740 predString->print_cr("<u range");
741 tty->print(predString->as_string());
742 }
737 return bol; 743 return bol;
738 } 744 }
739 745
740 //------------------------------ loop_predication_impl-------------------------- 746 //------------------------------ loop_predication_impl--------------------------
741 // Insert loop predicates for null checks and range checks 747 // Insert loop predicates for null checks and range checks
955 hoisted |= _next->loop_predication( phase); 961 hoisted |= _next->loop_predication( phase);
956 } 962 }
957 963
958 return hoisted; 964 return hoisted;
959 } 965 }
960

mercurial