src/share/vm/opto/loopTransform.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/opto/loopTransform.cpp	Wed Feb  3 11:49:48 2016
--- new/src/share/vm/opto/loopTransform.cpp	Wed Feb  3 11:49:48 2016

*** 2402,2425 **** --- 2402,2435 ---- } } if (needs_guard) { // Check for an obvious zero trip guard. Node* inctrl = PhaseIdealLoop::skip_loop_predicates(cl->in(LoopNode::EntryControl)); ! if (inctrl->Opcode() == Op_IfTrue || inctrl->Opcode() == Op_IfFalse) { + bool maybe_swapped = (inctrl->Opcode() == Op_IfFalse); // The test should look like just the backedge of a CountedLoop Node* iff = inctrl->in(0); if (iff->is_If()) { Node* bol = iff->in(1); - if (bol->is_Bool() && bol->as_Bool()->_test._test == cl->loopexit()->test_trip()) { + BoolTest test = bol->as_Bool()->_test; + if (maybe_swapped) { + test._test = test.commute(); + test._test = test.negate(); + } + if (test._test == cl->loopexit()->test_trip()) { Node* cmp = bol->in(1); if (cmp->is_Cmp() && cmp->in(1) == cl->init_trip() && cmp->in(2) == cl->limit()) { + int init_idx = maybe_swapped ? 2 : 1; + int limit_idx = 3 - init_idx; + if (cmp->is_Cmp() && cmp->in(init_idx) == cl->init_trip() && cmp->in(limit_idx) == cl->limit()) { needs_guard = false; } } } } } + } #ifndef PRODUCT if (PrintOpto) { tty->print("Removing empty loop with%s zero trip guard", needs_guard ? "out" : ""); this->dump_head();

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