Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/loopnode.cpp @ 6846:377508648226
8000313: C2 should use jlong for 64bit values
Summary: Replace all occurrences of long with jlong in C2 code.
Reviewed-by: kvn, twisti
author | vlivanov |
---|---|
date | Mon, 08 Oct 2012 13:02:13 -0700 |
parents | e626685e9f6c |
children | 8b3da8d14c93 |
comparison
equal
deleted
inserted
replaced
6845:9024b6b53ec2 | 6846:377508648226 |
---|---|
326 | 326 |
327 const TypeInt* init_t = gvn->type(init_trip)->is_int(); | 327 const TypeInt* init_t = gvn->type(init_trip)->is_int(); |
328 const TypeInt* limit_t = gvn->type(limit)->is_int(); | 328 const TypeInt* limit_t = gvn->type(limit)->is_int(); |
329 | 329 |
330 if (stride_con > 0) { | 330 if (stride_con > 0) { |
331 long init_p = (long)init_t->_lo + stride_con; | 331 jlong init_p = (jlong)init_t->_lo + stride_con; |
332 if (init_p > (long)max_jint || init_p > (long)limit_t->_hi) | 332 if (init_p > (jlong)max_jint || init_p > (jlong)limit_t->_hi) |
333 return false; // cyclic loop or this loop trips only once | 333 return false; // cyclic loop or this loop trips only once |
334 } else { | 334 } else { |
335 long init_p = (long)init_t->_hi + stride_con; | 335 jlong init_p = (jlong)init_t->_hi + stride_con; |
336 if (init_p < (long)min_jint || init_p < (long)limit_t->_lo) | 336 if (init_p < (jlong)min_jint || init_p < (jlong)limit_t->_lo) |
337 return false; // cyclic loop or this loop trips only once | 337 return false; // cyclic loop or this loop trips only once |
338 } | 338 } |
339 | 339 |
340 // ================================================= | 340 // ================================================= |
341 // ---- SUCCESS! Found A Trip-Counted Loop! ----- | 341 // ---- SUCCESS! Found A Trip-Counted Loop! ----- |
714 BoolTest::mask bt = cl->loopexit()->test_trip(); | 714 BoolTest::mask bt = cl->loopexit()->test_trip(); |
715 assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected"); | 715 assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected"); |
716 #endif | 716 #endif |
717 if (cl->has_exact_trip_count()) { | 717 if (cl->has_exact_trip_count()) { |
718 // Simple case: loop has constant boundaries. | 718 // Simple case: loop has constant boundaries. |
719 // Use longs to avoid integer overflow. | 719 // Use jlongs to avoid integer overflow. |
720 int stride_con = cl->stride_con(); | 720 int stride_con = cl->stride_con(); |
721 long init_con = cl->init_trip()->get_int(); | 721 jlong init_con = cl->init_trip()->get_int(); |
722 long limit_con = cl->limit()->get_int(); | 722 jlong limit_con = cl->limit()->get_int(); |
723 julong trip_cnt = cl->trip_count(); | 723 julong trip_cnt = cl->trip_count(); |
724 long final_con = init_con + trip_cnt*stride_con; | 724 jlong final_con = init_con + trip_cnt*stride_con; |
725 int final_int = (int)final_con; | 725 int final_int = (int)final_con; |
726 // The final value should be in integer range since the loop | 726 // The final value should be in integer range since the loop |
727 // is counted and the limit was checked for overflow. | 727 // is counted and the limit was checked for overflow. |
728 assert(final_con == (long)final_int, "final value should be integer"); | 728 assert(final_con == (jlong)final_int, "final value should be integer"); |
729 limit = _igvn.intcon(final_int); | 729 limit = _igvn.intcon(final_int); |
730 } else { | 730 } else { |
731 // Create new LoopLimit node to get exact limit (final iv value). | 731 // Create new LoopLimit node to get exact limit (final iv value). |
732 limit = new (C) LoopLimitNode(C, cl->init_trip(), cl->limit(), cl->stride()); | 732 limit = new (C) LoopLimitNode(C, cl->init_trip(), cl->limit(), cl->stride()); |
733 register_new_node(limit, cl->in(LoopNode::EntryControl)); | 733 register_new_node(limit, cl->in(LoopNode::EntryControl)); |
788 int stride_con = stride_t->is_int()->get_con(); | 788 int stride_con = stride_t->is_int()->get_con(); |
789 if (stride_con == 1) | 789 if (stride_con == 1) |
790 return NULL; // Identity | 790 return NULL; // Identity |
791 | 791 |
792 if (init_t->is_int()->is_con() && limit_t->is_int()->is_con()) { | 792 if (init_t->is_int()->is_con() && limit_t->is_int()->is_con()) { |
793 // Use longs to avoid integer overflow. | 793 // Use jlongs to avoid integer overflow. |
794 long init_con = init_t->is_int()->get_con(); | 794 jlong init_con = init_t->is_int()->get_con(); |
795 long limit_con = limit_t->is_int()->get_con(); | 795 jlong limit_con = limit_t->is_int()->get_con(); |
796 int stride_m = stride_con - (stride_con > 0 ? 1 : -1); | 796 int stride_m = stride_con - (stride_con > 0 ? 1 : -1); |
797 long trip_count = (limit_con - init_con + stride_m)/stride_con; | 797 jlong trip_count = (limit_con - init_con + stride_m)/stride_con; |
798 long final_con = init_con + stride_con*trip_count; | 798 jlong final_con = init_con + stride_con*trip_count; |
799 int final_int = (int)final_con; | 799 int final_int = (int)final_con; |
800 // The final value should be in integer range since the loop | 800 // The final value should be in integer range since the loop |
801 // is counted and the limit was checked for overflow. | 801 // is counted and the limit was checked for overflow. |
802 assert(final_con == (long)final_int, "final value should be integer"); | 802 assert(final_con == (jlong)final_int, "final value should be integer"); |
803 return TypeInt::make(final_int); | 803 return TypeInt::make(final_int); |
804 } | 804 } |
805 | 805 |
806 return bottom_type(); // TypeInt::INT | 806 return bottom_type(); // TypeInt::INT |
807 } | 807 } |
827 return NULL; | 827 return NULL; |
828 | 828 |
829 const TypeInt* init_t = phase->type(in(Init) )->is_int(); | 829 const TypeInt* init_t = phase->type(in(Init) )->is_int(); |
830 const TypeInt* limit_t = phase->type(in(Limit))->is_int(); | 830 const TypeInt* limit_t = phase->type(in(Limit))->is_int(); |
831 int stride_p; | 831 int stride_p; |
832 long lim, ini; | 832 jlong lim, ini; |
833 julong max; | 833 julong max; |
834 if (stride_con > 0) { | 834 if (stride_con > 0) { |
835 stride_p = stride_con; | 835 stride_p = stride_con; |
836 lim = limit_t->_hi; | 836 lim = limit_t->_hi; |
837 ini = init_t->_lo; | 837 ini = init_t->_lo; |