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

src/share/vm/opto/loopnode.cpp

Print this page
rev 9745 : 8145322: Code generated from unsafe loops can be slightly improved
Summary: improve code generated from checkIndex and unsafe loops
Reviewed-by:
rev 9746 : fix


 798       }
 799     }
 800   }
 801 
 802   // Free up intermediate goo
 803   _igvn.remove_dead_node(hook);
 804 
 805 #ifdef ASSERT
 806   assert(l->is_valid_counted_loop(), "counted loop shape is messed up");
 807   assert(l == loop->_head && l->phi() == phi && l->loopexit() == lex, "" );
 808 #endif
 809 #ifndef PRODUCT
 810   if (TraceLoopOpts) {
 811     tty->print("Counted      ");
 812     loop->dump_head();
 813   }
 814 #endif
 815 
 816   C->print_method(PHASE_AFTER_CLOOPS, 3);
 817 





 818   return true;
 819 }
 820 
 821 //----------------------exact_limit-------------------------------------------
 822 Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) {
 823   assert(loop->_head->is_CountedLoop(), "");
 824   CountedLoopNode *cl = loop->_head->as_CountedLoop();
 825   assert(cl->is_valid_counted_loop(), "");
 826 
 827   if (!LoopLimitCheck || ABS(cl->stride_con()) == 1 ||
 828       cl->limit()->Opcode() == Op_LoopLimit) {
 829     // Old code has exact limit (it could be incorrect in case of int overflow).
 830     // Loop limit is exact with stride == 1. And loop may already have exact limit.
 831     return cl->limit();
 832   }
 833   Node *limit = NULL;
 834 #ifdef ASSERT
 835   BoolTest::mask bt = cl->loopexit()->test_trip();
 836   assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected");
 837 #endif


3461         if (nstack.is_empty()) {
3462           // Finished all nodes on stack.
3463           // Process next node on the worklist.
3464           break;
3465         }
3466         // Get saved parent node and next use's index. Visit the rest of uses.
3467         n   = nstack.node();
3468         cnt = n->outcnt();
3469         i   = nstack.index();
3470         nstack.pop();
3471       }
3472     }
3473   }
3474 }
3475 
3476 //------------------------------build_loop_late_post---------------------------
3477 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping.
3478 // Second pass finds latest legal placement, and ideal loop placement.
3479 void PhaseIdealLoop::build_loop_late_post( Node *n ) {
3480 
3481   if (n->req() == 2 && n->Opcode() == Op_ConvI2L && !C->major_progress() && !_verify_only) {
3482     _igvn._worklist.push(n);  // Maybe we'll normalize it, if no more loops.
3483   }
3484 
3485 #ifdef ASSERT
3486   if (_verify_only && !n->is_CFG()) {
3487     // Check def-use domination.
3488     compute_lca_of_uses(n, get_ctrl(n), true /* verify */);
3489   }
3490 #endif
3491 
3492   // CFG and pinned nodes already handled
3493   if( n->in(0) ) {
3494     if( n->in(0)->is_top() ) return; // Dead?
3495 
3496     // We'd like +VerifyLoopOptimizations to not believe that Mod's/Loads
3497     // _must_ be pinned (they have to observe their control edge of course).
3498     // Unlike Stores (which modify an unallocable resource, the memory
3499     // state), Mods/Loads can float around.  So free them up.
3500     bool pinned = true;
3501     switch( n->Opcode() ) {




 798       }
 799     }
 800   }
 801 
 802   // Free up intermediate goo
 803   _igvn.remove_dead_node(hook);
 804 
 805 #ifdef ASSERT
 806   assert(l->is_valid_counted_loop(), "counted loop shape is messed up");
 807   assert(l == loop->_head && l->phi() == phi && l->loopexit() == lex, "" );
 808 #endif
 809 #ifndef PRODUCT
 810   if (TraceLoopOpts) {
 811     tty->print("Counted      ");
 812     loop->dump_head();
 813   }
 814 #endif
 815 
 816   C->print_method(PHASE_AFTER_CLOOPS, 3);
 817 
 818   // Capture bounds of the loop in the induction variable Phi before
 819   // subsequent transformation (iteration splitting) obscures the
 820   // bounds
 821   l->phi()->as_Phi()->set_type(l->phi()->Value(&_igvn));
 822 
 823   return true;
 824 }
 825 
 826 //----------------------exact_limit-------------------------------------------
 827 Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) {
 828   assert(loop->_head->is_CountedLoop(), "");
 829   CountedLoopNode *cl = loop->_head->as_CountedLoop();
 830   assert(cl->is_valid_counted_loop(), "");
 831 
 832   if (!LoopLimitCheck || ABS(cl->stride_con()) == 1 ||
 833       cl->limit()->Opcode() == Op_LoopLimit) {
 834     // Old code has exact limit (it could be incorrect in case of int overflow).
 835     // Loop limit is exact with stride == 1. And loop may already have exact limit.
 836     return cl->limit();
 837   }
 838   Node *limit = NULL;
 839 #ifdef ASSERT
 840   BoolTest::mask bt = cl->loopexit()->test_trip();
 841   assert(bt == BoolTest::lt || bt == BoolTest::gt, "canonical test is expected");
 842 #endif


3466         if (nstack.is_empty()) {
3467           // Finished all nodes on stack.
3468           // Process next node on the worklist.
3469           break;
3470         }
3471         // Get saved parent node and next use's index. Visit the rest of uses.
3472         n   = nstack.node();
3473         cnt = n->outcnt();
3474         i   = nstack.index();
3475         nstack.pop();
3476       }
3477     }
3478   }
3479 }
3480 
3481 //------------------------------build_loop_late_post---------------------------
3482 // Put Data nodes into some loop nest, by setting the _nodes[]->loop mapping.
3483 // Second pass finds latest legal placement, and ideal loop placement.
3484 void PhaseIdealLoop::build_loop_late_post( Node *n ) {
3485 
3486   if (n->req() == 2 && (n->Opcode() == Op_ConvI2L || n->Opcode() == Op_CastII) && !C->major_progress() && !_verify_only) {
3487     _igvn._worklist.push(n);  // Maybe we'll normalize it, if no more loops.
3488   }
3489 
3490 #ifdef ASSERT
3491   if (_verify_only && !n->is_CFG()) {
3492     // Check def-use domination.
3493     compute_lca_of_uses(n, get_ctrl(n), true /* verify */);
3494   }
3495 #endif
3496 
3497   // CFG and pinned nodes already handled
3498   if( n->in(0) ) {
3499     if( n->in(0)->is_top() ) return; // Dead?
3500 
3501     // We'd like +VerifyLoopOptimizations to not believe that Mod's/Loads
3502     // _must_ be pinned (they have to observe their control edge of course).
3503     // Unlike Stores (which modify an unallocable resource, the memory
3504     // state), Mods/Loads can float around.  So free them up.
3505     bool pinned = true;
3506     switch( n->Opcode() ) {


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