869
870 //------------------------------insert_pre_post_loops--------------------------
871 // Insert pre and post loops. If peel_only is set, the pre-loop can not have
872 // more iterations added. It acts as a 'peel' only, no lower-bound RCE, no
873 // alignment. Useful to unroll loops that do no array accesses.
874 void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_new, bool peel_only ) {
875
876 #ifndef PRODUCT
877 if (TraceLoopOpts) {
878 if (peel_only)
879 tty->print("PeelMainPost ");
880 else
881 tty->print("PreMainPost ");
882 loop->dump_head();
883 }
884 #endif
885 C->set_major_progress();
886
887 // Find common pieces of the loop being guarded with pre & post loops
888 CountedLoopNode *main_head = loop->_head->as_CountedLoop();
889 assert( main_head->is_normal_loop(), "" );
890 CountedLoopEndNode *main_end = main_head->loopexit();
891 assert( main_end->outcnt() == 2, "1 true, 1 false path only" );
892 uint dd_main_head = dom_depth(main_head);
893 uint max = main_head->outcnt();
894
895 Node *pre_header= main_head->in(LoopNode::EntryControl);
896 Node *init = main_head->init_trip();
897 Node *incr = main_end ->incr();
898 Node *limit = main_end ->limit();
899 Node *stride = main_end ->stride();
900 Node *cmp = main_end ->cmp_node();
901 BoolTest::mask b_test = main_end->test_trip();
902
903 // Need only 1 user of 'bol' because I will be hacking the loop bounds.
904 Node *bol = main_end->in(CountedLoopEndNode::TestValue);
905 if( bol->outcnt() != 1 ) {
906 bol = bol->clone();
907 register_new_node(bol,main_end->in(CountedLoopEndNode::TestControl));
908 _igvn.hash_delete(main_end);
909 main_end->set_req(CountedLoopEndNode::TestValue, bol);
910 }
2537 msg_node = store;
2538 }
2539
2540 if (msg != NULL) {
2541 #ifndef PRODUCT
2542 if (TraceOptimizeFill) {
2543 tty->print_cr("not fill intrinsic: %s", msg);
2544 if (msg_node != NULL) msg_node->dump();
2545 }
2546 #endif
2547 return false;
2548 }
2549
2550 // No make sure all the other nodes in the loop can be handled
2551 VectorSet ok(Thread::current()->resource_area());
2552
2553 // store related values are ok
2554 ok.set(store->_idx);
2555 ok.set(store->in(MemNode::Memory)->_idx);
2556
2557 // Loop structure is ok
2558 ok.set(head->_idx);
2559 ok.set(head->loopexit()->_idx);
2560 ok.set(head->phi()->_idx);
2561 ok.set(head->incr()->_idx);
2562 ok.set(head->loopexit()->cmp_node()->_idx);
2563 ok.set(head->loopexit()->in(1)->_idx);
2564
2565 // Address elements are ok
2566 if (con) ok.set(con->_idx);
2567 if (shift) ok.set(shift->_idx);
2568 if (conv) ok.set(conv->_idx);
2569
2570 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) {
2571 Node* n = lpt->_body.at(i);
2572 if (n->outcnt() == 0) continue; // Ignore dead
2573 if (ok.test(n->_idx)) continue;
2574 // Backedge projection is ok
2575 if (n->is_IfTrue() && n->in(0) == head->loopexit()) continue;
2576 if (!n->is_AddP()) {
2577 msg = "unhandled node";
2578 msg_node = n;
2579 break;
2580 }
2581 }
2582
2583 // Make sure no unexpected values are used outside the loop
|
869
870 //------------------------------insert_pre_post_loops--------------------------
871 // Insert pre and post loops. If peel_only is set, the pre-loop can not have
872 // more iterations added. It acts as a 'peel' only, no lower-bound RCE, no
873 // alignment. Useful to unroll loops that do no array accesses.
874 void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_new, bool peel_only ) {
875
876 #ifndef PRODUCT
877 if (TraceLoopOpts) {
878 if (peel_only)
879 tty->print("PeelMainPost ");
880 else
881 tty->print("PreMainPost ");
882 loop->dump_head();
883 }
884 #endif
885 C->set_major_progress();
886
887 // Find common pieces of the loop being guarded with pre & post loops
888 CountedLoopNode *main_head = loop->_head->as_CountedLoop();
889 guarantee(main_head != NULL, "no main head loop node");
890 assert( main_head->is_normal_loop(), "" );
891 CountedLoopEndNode *main_end = main_head->loopexit();
892 guarantee(main_end != NULL, "no main end loop node");
893 assert( main_end->outcnt() == 2, "1 true, 1 false path only" );
894 uint dd_main_head = dom_depth(main_head);
895 uint max = main_head->outcnt();
896
897 Node *pre_header= main_head->in(LoopNode::EntryControl);
898 Node *init = main_head->init_trip();
899 Node *incr = main_end ->incr();
900 Node *limit = main_end ->limit();
901 Node *stride = main_end ->stride();
902 Node *cmp = main_end ->cmp_node();
903 BoolTest::mask b_test = main_end->test_trip();
904
905 // Need only 1 user of 'bol' because I will be hacking the loop bounds.
906 Node *bol = main_end->in(CountedLoopEndNode::TestValue);
907 if( bol->outcnt() != 1 ) {
908 bol = bol->clone();
909 register_new_node(bol,main_end->in(CountedLoopEndNode::TestControl));
910 _igvn.hash_delete(main_end);
911 main_end->set_req(CountedLoopEndNode::TestValue, bol);
912 }
2539 msg_node = store;
2540 }
2541
2542 if (msg != NULL) {
2543 #ifndef PRODUCT
2544 if (TraceOptimizeFill) {
2545 tty->print_cr("not fill intrinsic: %s", msg);
2546 if (msg_node != NULL) msg_node->dump();
2547 }
2548 #endif
2549 return false;
2550 }
2551
2552 // No make sure all the other nodes in the loop can be handled
2553 VectorSet ok(Thread::current()->resource_area());
2554
2555 // store related values are ok
2556 ok.set(store->_idx);
2557 ok.set(store->in(MemNode::Memory)->_idx);
2558
2559 CountedLoopEndNode* head_exit = head->loopexit();
2560 guarantee(head_exit != NULL, "no head exit loop node");
2561
2562 // Loop structure is ok
2563 ok.set(head->_idx);
2564 ok.set(head_exit->_idx);
2565 ok.set(head->phi()->_idx);
2566 ok.set(head->incr()->_idx);
2567 ok.set(head_exit->cmp_node()->_idx);
2568 ok.set(head_exit->in(1)->_idx);
2569
2570 // Address elements are ok
2571 if (con) ok.set(con->_idx);
2572 if (shift) ok.set(shift->_idx);
2573 if (conv) ok.set(conv->_idx);
2574
2575 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) {
2576 Node* n = lpt->_body.at(i);
2577 if (n->outcnt() == 0) continue; // Ignore dead
2578 if (ok.test(n->_idx)) continue;
2579 // Backedge projection is ok
2580 if (n->is_IfTrue() && n->in(0) == head->loopexit()) continue;
2581 if (!n->is_AddP()) {
2582 msg = "unhandled node";
2583 msg_node = n;
2584 break;
2585 }
2586 }
2587
2588 // Make sure no unexpected values are used outside the loop
|