diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp index 3b33547197479..cc6b6658ac74a 100644 --- a/src/hotspot/share/opto/macro.cpp +++ b/src/hotspot/share/opto/macro.cpp @@ -2563,11 +2563,8 @@ void PhaseMacroExpand::eliminate_macro_nodes() { bool progress = true; while (progress) { progress = false; - for (int i = C->macro_count(); i > 0; i--) { - if (i > C->macro_count()) { - i = C->macro_count(); // more than 1 element can be eliminated at once - } - Node* n = C->macro_node(i-1); + for (int i = C->macro_count(); i > 0; i = MIN2(i - 1, C->macro_count())) { // more than 1 element can be eliminated at once + Node* n = C->macro_node(i - 1); bool success = false; DEBUG_ONLY(int old_macro_count = C->macro_count();) if (n->is_AbstractLock()) { @@ -2582,11 +2579,8 @@ void PhaseMacroExpand::eliminate_macro_nodes() { progress = true; while (progress) { progress = false; - for (int i = C->macro_count(); i > 0; i--) { - if (i > C->macro_count()) { - i = C->macro_count(); // more than 1 element can be eliminated at once - } - Node* n = C->macro_node(i-1); + for (int i = C->macro_count(); i > 0; i = MIN2(i - 1, C->macro_count())) { // more than 1 element can be eliminated at once + Node* n = C->macro_node(i - 1); bool success = false; DEBUG_ONLY(int old_macro_count = C->macro_count();) switch (n->class_id()) {