@@ -1042,7 +1042,7 @@ bool IdealLoopTree::policy_unroll(PhaseIdealLoop *phase) {
1042
1042
}
1043
1043
1044
1044
// Only attempt slp analysis when user controls do not prohibit it
1045
- if (!cl-> range_checks_present () && (LoopMaxUnroll > _local_loop_unroll_factor)) {
1045
+ if (!range_checks_present () && (LoopMaxUnroll > _local_loop_unroll_factor)) {
1046
1046
// Once policy_slp_analysis succeeds, mark the loop with the
1047
1047
// maximal unroll factor so that we minimize analysis passes
1048
1048
if (future_unroll_cnt >= _local_loop_unroll_factor) {
@@ -1916,7 +1916,7 @@ void PhaseIdealLoop::insert_scalar_rced_post_loop(IdealLoopTree *loop, Node_List
1916
1916
CountedLoopNode *cl = loop->_head ->as_CountedLoop ();
1917
1917
1918
1918
// only process RCE'd main loops
1919
- if (!cl->is_main_loop () || cl ->range_checks_present ()) return ;
1919
+ if (!cl->is_main_loop () || loop ->range_checks_present ()) return ;
1920
1920
1921
1921
#ifndef PRODUCT
1922
1922
if (TraceLoopOpts) {
@@ -3003,7 +3003,7 @@ Node* PhaseIdealLoop::add_range_check_predicate(IdealLoopTree* loop, CountedLoop
3003
3003
3004
3004
// ------------------------------do_range_check---------------------------------
3005
3005
// Eliminate range-checks and other trip-counter vs loop-invariant tests.
3006
- int PhaseIdealLoop::do_range_check (IdealLoopTree *loop, Node_List &old_new) {
3006
+ void PhaseIdealLoop::do_range_check (IdealLoopTree *loop, Node_List &old_new) {
3007
3007
#ifndef PRODUCT
3008
3008
if (PrintOpto && VerifyLoopOptimizations) {
3009
3009
tty->print (" Range Check Elimination " );
@@ -3016,12 +3016,10 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3016
3016
3017
3017
assert (RangeCheckElimination, " " );
3018
3018
CountedLoopNode *cl = loop->_head ->as_CountedLoop ();
3019
- // If we fail before trying to eliminate range checks, set multiversion state
3020
- int closed_range_checks = 1 ;
3021
3019
3022
3020
// protect against stride not being a constant
3023
3021
if (!cl->stride_is_con ()) {
3024
- return closed_range_checks ;
3022
+ return ;
3025
3023
}
3026
3024
// Find the trip counter; we are iteration splitting based on it
3027
3025
Node *trip_counter = cl->phi ();
@@ -3033,7 +3031,7 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3033
3031
// Opaque1 node is optimized away and then another round
3034
3032
// of loop opts attempted.
3035
3033
if (cl->is_canonical_loop_entry () == NULL ) {
3036
- return closed_range_checks ;
3034
+ return ;
3037
3035
}
3038
3036
3039
3037
// Need to find the main-loop zero-trip guard
@@ -3047,7 +3045,7 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3047
3045
Node *p_f = iffm->in (0 );
3048
3046
// pre loop may have been optimized out
3049
3047
if (p_f->Opcode () != Op_IfFalse) {
3050
- return closed_range_checks ;
3048
+ return ;
3051
3049
}
3052
3050
CountedLoopEndNode *pre_end = p_f->in (0 )->as_CountedLoopEnd ();
3053
3051
assert (pre_end->loopnode ()->is_pre_loop (), " " );
@@ -3056,7 +3054,7 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3056
3054
// optimized away and then another round of loop opts attempted.
3057
3055
// We can not optimize this particular loop in that case.
3058
3056
if (pre_opaq1->Opcode () != Op_Opaque1) {
3059
- return closed_range_checks ;
3057
+ return ;
3060
3058
}
3061
3059
Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1;
3062
3060
Node *pre_limit = pre_opaq->in (1 );
@@ -3068,7 +3066,7 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3068
3066
// pre-loop Opaque1 node.
3069
3067
Node *orig_limit = pre_opaq->original_loop_limit ();
3070
3068
if (orig_limit == NULL || _igvn.type (orig_limit) == Type::TOP) {
3071
- return closed_range_checks ;
3069
+ return ;
3072
3070
}
3073
3071
// Must know if its a count-up or count-down loop
3074
3072
@@ -3081,10 +3079,6 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3081
3079
set_ctrl (one, C->root ());
3082
3080
set_ctrl (mini, C->root ());
3083
3081
3084
- // Count number of range checks and reduce by load range limits, if zero,
3085
- // the loop is in canonical form to multiversion.
3086
- closed_range_checks = 0 ;
3087
-
3088
3082
Node* predicate_proj = cl->skip_strip_mined ()->in (LoopNode::EntryControl);
3089
3083
assert (predicate_proj->is_Proj () && predicate_proj->in (0 )->is_If (), " if projection only" );
3090
3084
@@ -3095,7 +3089,6 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3095
3089
iff->Opcode () == Op_RangeCheck) { // Test?
3096
3090
// Test is an IfNode, has 2 projections. If BOTH are in the loop
3097
3091
// we need loop unswitching instead of iteration splitting.
3098
- closed_range_checks++;
3099
3092
Node *exit = loop->is_loop_exit (iff);
3100
3093
if (!exit ) continue ;
3101
3094
int flip = (exit ->Opcode () == Op_IfTrue) ? 1 : 0 ;
@@ -3264,9 +3257,6 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3264
3257
--imax;
3265
3258
}
3266
3259
}
3267
- if (int_limit->Opcode () == Op_LoadRange) {
3268
- closed_range_checks--;
3269
- }
3270
3260
} // End of is IF
3271
3261
}
3272
3262
if (predicate_proj != cl->skip_strip_mined ()->in (LoopNode::EntryControl)) {
@@ -3316,32 +3306,19 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
3316
3306
assert (opqzm->outcnt () == 1 , " cannot hack shared node" );
3317
3307
_igvn.replace_input_of (opqzm, 1 , main_limit);
3318
3308
3319
- return closed_range_checks ;
3309
+ return ;
3320
3310
}
3321
3311
3322
- // ------------------------------has_range_checks-------------------------------
3323
- // Check to see if RCE cleaned the current loop of range-checks.
3324
- void PhaseIdealLoop::has_range_checks (IdealLoopTree *loop) {
3325
- assert (RangeCheckElimination, " " );
3326
-
3327
- // skip if not a counted loop
3328
- if (!loop->is_counted ()) return ;
3329
-
3330
- CountedLoopNode *cl = loop->_head ->as_CountedLoop ();
3331
-
3332
- // skip this loop if it is already checked
3333
- if (cl->has_been_range_checked ()) return ;
3334
-
3335
- // Now check for existence of range checks
3336
- for (uint i = 0 ; i < loop->_body .size (); i++) {
3337
- Node *iff = loop->_body [i];
3312
+ bool IdealLoopTree::compute_has_range_checks () const {
3313
+ assert (_head->is_CountedLoop (), " " );
3314
+ for (uint i = 0 ; i < _body.size (); i++) {
3315
+ Node *iff = _body[i];
3338
3316
int iff_opc = iff->Opcode ();
3339
3317
if (iff_opc == Op_If || iff_opc == Op_RangeCheck) {
3340
- cl->mark_has_range_checks ();
3341
- break ;
3318
+ return true ;
3342
3319
}
3343
3320
}
3344
- cl-> set_has_been_range_checked () ;
3321
+ return false ;
3345
3322
}
3346
3323
3347
3324
// -------------------------multi_version_post_loops----------------------------
@@ -4007,13 +3984,7 @@ bool IdealLoopTree::iteration_split_impl(PhaseIdealLoop *phase, Node_List &old_n
4007
3984
// with full checks, but the main-loop with no checks. Remove said checks
4008
3985
// from the main body.
4009
3986
if (should_rce) {
4010
- if (phase->do_range_check (this , old_new) != 0 ) {
4011
- cl->mark_has_range_checks ();
4012
- } else {
4013
- cl->clear_has_range_checks ();
4014
- }
4015
- } else if (PostLoopMultiversioning) {
4016
- phase->has_range_checks (this );
3987
+ phase->do_range_check (this , old_new);
4017
3988
}
4018
3989
4019
3990
if (should_unroll && !should_peel && PostLoopMultiversioning &&
0 commit comments