916 const TypeInt* lo = phase->type(init)->isa_int(); |
916 const TypeInt* lo = phase->type(init)->isa_int(); |
917 const TypeInt* hi = phase->type(limit)->isa_int(); |
917 const TypeInt* hi = phase->type(limit)->isa_int(); |
918 const TypeInt* stride_t = phase->type(stride)->isa_int(); |
918 const TypeInt* stride_t = phase->type(stride)->isa_int(); |
919 if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here |
919 if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here |
920 assert(stride_t->_hi >= stride_t->_lo, "bad stride type"); |
920 assert(stride_t->_hi >= stride_t->_lo, "bad stride type"); |
921 if (stride_t->_hi < 0) { // Down-counter loop |
921 BoolTest::mask bt = l->loopexit()->test_trip(); |
922 swap(lo, hi); |
922 // If the loop exit condition is "not equal", the condition |
923 return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3); |
923 // would not trigger if init > limit (if stride > 0) or if |
924 } else if (stride_t->_lo >= 0) { |
924 // init < limit if (stride > 0) so we can't deduce bounds |
925 return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3); |
925 // for the iv from the exit condition. |
|
926 if (bt != BoolTest::ne) { |
|
927 if (stride_t->_hi < 0) { // Down-counter loop |
|
928 swap(lo, hi); |
|
929 return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3); |
|
930 } else if (stride_t->_lo >= 0) { |
|
931 return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3); |
|
932 } |
926 } |
933 } |
927 } |
934 } |
928 } |
935 } |
929 } else if (l->in(LoopNode::LoopBackControl) != NULL && |
936 } else if (l->in(LoopNode::LoopBackControl) != NULL && |
930 in(LoopNode::EntryControl) != NULL && |
937 in(LoopNode::EntryControl) != NULL && |
931 phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) { |
938 phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) { |
932 // During CCP, if we saturate the type of a counted loop's Phi |
939 // During CCP, if we saturate the type of a counted loop's Phi |
933 // before the special code for counted loop above has a chance |
940 // before the special code for counted loop above has a chance |
934 // to run (that is as long as the type of the backedge's control |
941 // to run (that is as long as the type of the backedge's control |
935 // is top), we might end up with non monotonic types |
942 // is top), we might end up with non monotonic types |
936 return phase->type(in(LoopNode::EntryControl)); |
943 return phase->type(in(LoopNode::EntryControl))->filter_speculative(_type); |
937 } |
944 } |
938 } |
945 } |
939 |
946 |
940 // Until we have harmony between classes and interfaces in the type |
947 // Until we have harmony between classes and interfaces in the type |
941 // lattice, we must tread carefully around phis which implicitly |
948 // lattice, we must tread carefully around phis which implicitly |