1063 if (l && ((const Node*)l->phi() == this)) { // Trip counted loop! 1064 // protect against init_trip() or limit() returning NULL 1065 if (l->can_be_counted_loop(phase)) { 1066 const Node *init = l->init_trip(); 1067 const Node *limit = l->limit(); 1068 const Node* stride = l->stride(); 1069 if (init != NULL && limit != NULL && stride != NULL) { 1070 const TypeInt* lo = phase->type(init)->isa_int(); 1071 const TypeInt* hi = phase->type(limit)->isa_int(); 1072 const TypeInt* stride_t = phase->type(stride)->isa_int(); 1073 if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here 1074 assert(stride_t->_hi >= stride_t->_lo, "bad stride type"); 1075 BoolTest::mask bt = l->loopexit()->test_trip(); 1076 // If the loop exit condition is "not equal", the condition 1077 // would not trigger if init > limit (if stride > 0) or if 1078 // init < limit if (stride > 0) so we can't deduce bounds 1079 // for the iv from the exit condition. 1080 if (bt != BoolTest::ne) { 1081 if (stride_t->_hi < 0) { // Down-counter loop 1082 swap(lo, hi); 1083 return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3); 1084 } else if (stride_t->_lo >= 0) { 1085 return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3); 1086 } 1087 } 1088 } 1089 } 1090 } else if (l->in(LoopNode::LoopBackControl) != NULL && 1091 in(LoopNode::EntryControl) != NULL && 1092 phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) { 1093 // During CCP, if we saturate the type of a counted loop's Phi 1094 // before the special code for counted loop above has a chance 1095 // to run (that is as long as the type of the backedge's control 1096 // is top), we might end up with non monotonic types 1097 return phase->type(in(LoopNode::EntryControl))->filter_speculative(_type); 1098 } 1099 } 1100 1101 // Until we have harmony between classes and interfaces in the type 1102 // lattice, we must tread carefully around phis which implicitly 1103 // convert the one to the other. 1104 const TypePtr* ttp = _type->make_ptr(); 1105 const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL; | 1063 if (l && ((const Node*)l->phi() == this)) { // Trip counted loop! 1064 // protect against init_trip() or limit() returning NULL 1065 if (l->can_be_counted_loop(phase)) { 1066 const Node *init = l->init_trip(); 1067 const Node *limit = l->limit(); 1068 const Node* stride = l->stride(); 1069 if (init != NULL && limit != NULL && stride != NULL) { 1070 const TypeInt* lo = phase->type(init)->isa_int(); 1071 const TypeInt* hi = phase->type(limit)->isa_int(); 1072 const TypeInt* stride_t = phase->type(stride)->isa_int(); 1073 if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here 1074 assert(stride_t->_hi >= stride_t->_lo, "bad stride type"); 1075 BoolTest::mask bt = l->loopexit()->test_trip(); 1076 // If the loop exit condition is "not equal", the condition 1077 // would not trigger if init > limit (if stride > 0) or if 1078 // init < limit if (stride > 0) so we can't deduce bounds 1079 // for the iv from the exit condition. 1080 if (bt != BoolTest::ne) { 1081 if (stride_t->_hi < 0) { // Down-counter loop 1082 swap(lo, hi); 1083 return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3)->filter_speculative(_type); 1084 } else if (stride_t->_lo >= 0) { 1085 return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3)->filter_speculative(_type); 1086 } 1087 } 1088 } 1089 } 1090 } else if (l->in(LoopNode::LoopBackControl) != NULL && 1091 in(LoopNode::EntryControl) != NULL && 1092 phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) { 1093 // During CCP, if we saturate the type of a counted loop's Phi 1094 // before the special code for counted loop above has a chance 1095 // to run (that is as long as the type of the backedge's control 1096 // is top), we might end up with non monotonic types 1097 return phase->type(in(LoopNode::EntryControl))->filter_speculative(_type); 1098 } 1099 } 1100 1101 // Until we have harmony between classes and interfaces in the type 1102 // lattice, we must tread carefully around phis which implicitly 1103 // convert the one to the other. 1104 const TypePtr* ttp = _type->make_ptr(); 1105 const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL; |