src/share/vm/opto/loopopts.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/loopopts.cpp

Print this page
rev 7999 : 8073480: C2 should optimize explicit range checks
Summary: explicit range checks should be recognized by C2
Reviewed-by:


 224   // If I dont have a reachable TRUE and FALSE path following the IfNode then
 225   // I can assume this path reaches an infinite loop.  In this case it's not
 226   // important to optimize the data Nodes - either the whole compilation will
 227   // be tossed or this path (and all data Nodes) will go dead.
 228   if (iff->outcnt() != 2) return;
 229 
 230   // Make control-dependent data Nodes on the live path (path that will remain
 231   // once the dominated IF is removed) become control-dependent on the
 232   // dominating projection.
 233   Node* dp = iff->as_If()->proj_out(pop == Op_IfTrue);
 234 
 235   // Loop predicates may have depending checks which should not
 236   // be skipped. For example, range check predicate has two checks
 237   // for lower and upper bounds.
 238   if (dp == NULL)
 239     return;
 240 
 241   ProjNode* dp_proj  = dp->as_Proj();
 242   ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp_proj->_con)->as_Proj();
 243   if (exclude_loop_predicate &&
 244       (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) ||
 245        unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_range_check))) {
 246     // If this is a range check (IfNode::is_range_check), do not
 247     // reorder because Compile::allow_range_check_smearing might have
 248     // changed the check.
 249     return; // Let IGVN transformation change control dependence.
 250   }
 251 
 252   IdealLoopTree *old_loop = get_loop(dp);
 253 
 254   for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
 255     Node* cd = dp->fast_out(i); // Control-dependent node
 256     if (cd->depends_only_on_test()) {
 257       assert(cd->in(0) == dp, "");
 258       _igvn.replace_input_of(cd, 0, prevdom);
 259       set_early_ctrl(cd);
 260       IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
 261       if (old_loop != new_loop) {
 262         if (!old_loop->_child) old_loop->_body.yank(cd);
 263         if (!new_loop->_child) new_loop->_body.push(cd);
 264       }
 265       --i;




 224   // If I dont have a reachable TRUE and FALSE path following the IfNode then
 225   // I can assume this path reaches an infinite loop.  In this case it's not
 226   // important to optimize the data Nodes - either the whole compilation will
 227   // be tossed or this path (and all data Nodes) will go dead.
 228   if (iff->outcnt() != 2) return;
 229 
 230   // Make control-dependent data Nodes on the live path (path that will remain
 231   // once the dominated IF is removed) become control-dependent on the
 232   // dominating projection.
 233   Node* dp = iff->as_If()->proj_out(pop == Op_IfTrue);
 234 
 235   // Loop predicates may have depending checks which should not
 236   // be skipped. For example, range check predicate has two checks
 237   // for lower and upper bounds.
 238   if (dp == NULL)
 239     return;
 240 
 241   ProjNode* dp_proj  = dp->as_Proj();
 242   ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp_proj->_con)->as_Proj();
 243   if (exclude_loop_predicate &&
 244       (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL ||
 245        unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_range_check) != NULL)) {
 246     // If this is a range check (IfNode::is_range_check), do not
 247     // reorder because Compile::allow_range_check_smearing might have
 248     // changed the check.
 249     return; // Let IGVN transformation change control dependence.
 250   }
 251 
 252   IdealLoopTree *old_loop = get_loop(dp);
 253 
 254   for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
 255     Node* cd = dp->fast_out(i); // Control-dependent node
 256     if (cd->depends_only_on_test()) {
 257       assert(cd->in(0) == dp, "");
 258       _igvn.replace_input_of(cd, 0, prevdom);
 259       set_early_ctrl(cd);
 260       IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
 261       if (old_loop != new_loop) {
 262         if (!old_loop->_child) old_loop->_body.yank(cd);
 263         if (!new_loop->_child) new_loop->_body.push(cd);
 264       }
 265       --i;


src/share/vm/opto/loopopts.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File