462 PhaseIterGVN();
463
464 // Reset IGVN: call deconstructor, and placement new.
465 void reset() {
466 this->~PhaseIterGVN();
467 ::new (static_cast<void*>(this)) PhaseIterGVN();
468 }
469
470 // Reset IGVN with another: call deconstructor, and placement new.
471 // Achieves the same as the following (but without move constructors):
472 // igvn = PhaseIterGVN(other);
473 void reset_from_igvn(PhaseIterGVN* other) {
474 if (this != other) {
475 this->~PhaseIterGVN();
476 ::new (static_cast<void*>(this)) PhaseIterGVN(other);
477 }
478 }
479
480 // Idealize new Node 'n' with respect to its inputs and its value
481 virtual Node *transform( Node *a_node );
482 virtual void record_for_igvn(Node *n) { }
483
484 // Iterative worklist. Reference to "C->igvn_worklist()".
485 Unique_Node_List &_worklist;
486
487 // Given def-use info and an initial worklist, apply Node::Ideal,
488 // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU
489 // and dominator info to a fixed point.
490 void optimize();
491 #ifdef ASSERT
492 void verify_optimize();
493 bool verify_Value_for(Node* n);
494 bool verify_Ideal_for(Node* n, bool can_reshape);
495 bool verify_Identity_for(Node* n);
496 void verify_empty_worklist(Node* n);
497 #endif
498
499 #ifndef PRODUCT
500 void trace_PhaseIterGVN(Node* n, Node* nn, const Type* old_type);
501 void init_verifyPhaseIterGVN();
502 void verify_PhaseIterGVN();
521
522 // Kill all inputs to a dead node, recursively making more dead nodes.
523 // The Node must be dead locally, i.e., have no uses.
524 void remove_dead_node( Node *dead ) {
525 assert(dead->outcnt() == 0 && !dead->is_top(), "node must be dead");
526 remove_globally_dead_node(dead);
527 }
528
529 // Add users of 'n' to worklist
530 static void add_users_to_worklist0(Node* n, Unique_Node_List& worklist);
531 static void add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_List& worklist);
532 void add_users_to_worklist(Node* n);
533
534 // Replace old node with new one.
535 void replace_node( Node *old, Node *nn ) {
536 add_users_to_worklist(old);
537 hash_delete(old); // Yank from hash before hacking edges
538 subsume_node(old, nn);
539 }
540
541 // Delayed node rehash: remove a node from the hash table and rehash it during
542 // next optimizing pass
543 void rehash_node_delayed(Node* n) {
544 hash_delete(n);
545 _worklist.push(n);
546 }
547
548 // Replace ith edge of "n" with "in"
549 void replace_input_of(Node* n, uint i, Node* in) {
550 rehash_node_delayed(n);
551 n->set_req_X(i, in, this);
552 }
553
554 // Add "in" as input (req) of "n"
555 void add_input_to(Node* n, Node* in) {
556 rehash_node_delayed(n);
557 n->add_req(in);
558 }
559
560 // Delete ith edge of "n"
612
613 //------------------------------PhaseCCP---------------------------------------
614 // Phase for performing global Conditional Constant Propagation.
615 // Should be replaced with combined CCP & GVN someday.
616 class PhaseCCP : public PhaseIterGVN {
617 Unique_Node_List _root_and_safepoints;
618 Unique_Node_List _maybe_top_type_nodes;
619 // Non-recursive. Use analysis to transform single Node.
620 virtual Node* transform_once(Node* n);
621
622 Node* fetch_next_node(Unique_Node_List& worklist);
623 static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN;
624
625 void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const;
626 void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const;
627 void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const;
628 void push_phis(Unique_Node_List& worklist, const Node* use) const;
629 static void push_catch(Unique_Node_List& worklist, const Node* use);
630 void push_cmpu(Unique_Node_List& worklist, const Node* use) const;
631 static void push_counted_loop_phi(Unique_Node_List& worklist, Node* parent, const Node* use);
632 void push_loadp(Unique_Node_List& worklist, const Node* use) const;
633 static void push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use);
634 void push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
635 void push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
636 void push_opaque_zero_trip_guard(Unique_Node_List& worklist, const Node* use) const;
637 void push_bool_with_cmpu_and_mask(Unique_Node_List& worklist, const Node* use) const;
638 void push_bool_matching_case1b(Unique_Node_List& worklist, const Node* cmpu) const;
639
640 public:
641 PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
642 NOT_PRODUCT( ~PhaseCCP(); )
643
644 // Worklist algorithm identifies constants
645 void analyze();
646 #ifdef ASSERT
647 void verify_type(Node* n, const Type* tnew, const Type* told);
648 // For every node n on verify list, check if type(n) == n->Value()
649 void verify_analyze(Unique_Node_List& worklist_verify);
650 #endif
651 // Recursive traversal of program. Used analysis to modify program.
|
462 PhaseIterGVN();
463
464 // Reset IGVN: call deconstructor, and placement new.
465 void reset() {
466 this->~PhaseIterGVN();
467 ::new (static_cast<void*>(this)) PhaseIterGVN();
468 }
469
470 // Reset IGVN with another: call deconstructor, and placement new.
471 // Achieves the same as the following (but without move constructors):
472 // igvn = PhaseIterGVN(other);
473 void reset_from_igvn(PhaseIterGVN* other) {
474 if (this != other) {
475 this->~PhaseIterGVN();
476 ::new (static_cast<void*>(this)) PhaseIterGVN(other);
477 }
478 }
479
480 // Idealize new Node 'n' with respect to its inputs and its value
481 virtual Node *transform( Node *a_node );
482 virtual void record_for_igvn(Node *n) { _worklist.push(n); }
483
484 // Iterative worklist. Reference to "C->igvn_worklist()".
485 Unique_Node_List &_worklist;
486
487 // Given def-use info and an initial worklist, apply Node::Ideal,
488 // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU
489 // and dominator info to a fixed point.
490 void optimize();
491 #ifdef ASSERT
492 void verify_optimize();
493 bool verify_Value_for(Node* n);
494 bool verify_Ideal_for(Node* n, bool can_reshape);
495 bool verify_Identity_for(Node* n);
496 void verify_empty_worklist(Node* n);
497 #endif
498
499 #ifndef PRODUCT
500 void trace_PhaseIterGVN(Node* n, Node* nn, const Type* old_type);
501 void init_verifyPhaseIterGVN();
502 void verify_PhaseIterGVN();
521
522 // Kill all inputs to a dead node, recursively making more dead nodes.
523 // The Node must be dead locally, i.e., have no uses.
524 void remove_dead_node( Node *dead ) {
525 assert(dead->outcnt() == 0 && !dead->is_top(), "node must be dead");
526 remove_globally_dead_node(dead);
527 }
528
529 // Add users of 'n' to worklist
530 static void add_users_to_worklist0(Node* n, Unique_Node_List& worklist);
531 static void add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_List& worklist);
532 void add_users_to_worklist(Node* n);
533
534 // Replace old node with new one.
535 void replace_node( Node *old, Node *nn ) {
536 add_users_to_worklist(old);
537 hash_delete(old); // Yank from hash before hacking edges
538 subsume_node(old, nn);
539 }
540
541 void replace_in_uses(Node* n, Node* m);
542
543 // Delayed node rehash: remove a node from the hash table and rehash it during
544 // next optimizing pass
545 void rehash_node_delayed(Node* n) {
546 hash_delete(n);
547 _worklist.push(n);
548 }
549
550 // Replace ith edge of "n" with "in"
551 void replace_input_of(Node* n, uint i, Node* in) {
552 rehash_node_delayed(n);
553 n->set_req_X(i, in, this);
554 }
555
556 // Add "in" as input (req) of "n"
557 void add_input_to(Node* n, Node* in) {
558 rehash_node_delayed(n);
559 n->add_req(in);
560 }
561
562 // Delete ith edge of "n"
614
615 //------------------------------PhaseCCP---------------------------------------
616 // Phase for performing global Conditional Constant Propagation.
617 // Should be replaced with combined CCP & GVN someday.
618 class PhaseCCP : public PhaseIterGVN {
619 Unique_Node_List _root_and_safepoints;
620 Unique_Node_List _maybe_top_type_nodes;
621 // Non-recursive. Use analysis to transform single Node.
622 virtual Node* transform_once(Node* n);
623
624 Node* fetch_next_node(Unique_Node_List& worklist);
625 static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN;
626
627 void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const;
628 void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const;
629 void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const;
630 void push_phis(Unique_Node_List& worklist, const Node* use) const;
631 static void push_catch(Unique_Node_List& worklist, const Node* use);
632 void push_cmpu(Unique_Node_List& worklist, const Node* use) const;
633 static void push_counted_loop_phi(Unique_Node_List& worklist, Node* parent, const Node* use);
634 static void push_cast(Unique_Node_List& worklist, const Node* use);
635 void push_loadp(Unique_Node_List& worklist, const Node* use) const;
636 static void push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use);
637 void push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
638 void push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
639 void push_opaque_zero_trip_guard(Unique_Node_List& worklist, const Node* use) const;
640 void push_bool_with_cmpu_and_mask(Unique_Node_List& worklist, const Node* use) const;
641 void push_bool_matching_case1b(Unique_Node_List& worklist, const Node* cmpu) const;
642
643 public:
644 PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
645 NOT_PRODUCT( ~PhaseCCP(); )
646
647 // Worklist algorithm identifies constants
648 void analyze();
649 #ifdef ASSERT
650 void verify_type(Node* n, const Type* tnew, const Type* told);
651 // For every node n on verify list, check if type(n) == n->Value()
652 void verify_analyze(Unique_Node_List& worklist_verify);
653 #endif
654 // Recursive traversal of program. Used analysis to modify program.
|