Mercurial > hg > truffle
comparison src/share/vm/opto/loopnode.hpp @ 2383:9dc311b8473e
7008866: Missing loop predicate for loop with multiple entries
Summary: Add predicates when loop head bytecode is parsed instead of when back branch bytecode is parsed.
Reviewed-by: never
author | kvn |
---|---|
date | Mon, 21 Mar 2011 11:28:14 -0700 |
parents | 194c9fdee631 |
children | 08eb13460b3a |
comparison
equal
deleted
inserted
replaced
2382:3ef1a1866a60 | 2383:9dc311b8473e |
---|---|
91 bool can_be_counted_loop(PhaseTransform* phase) const { | 91 bool can_be_counted_loop(PhaseTransform* phase) const { |
92 return req() == 3 && in(0) != NULL && | 92 return req() == 3 && in(0) != NULL && |
93 in(1) != NULL && phase->type(in(1)) != Type::TOP && | 93 in(1) != NULL && phase->type(in(1)) != Type::TOP && |
94 in(2) != NULL && phase->type(in(2)) != Type::TOP; | 94 in(2) != NULL && phase->type(in(2)) != Type::TOP; |
95 } | 95 } |
96 bool is_valid_counted_loop() const; | |
96 #ifndef PRODUCT | 97 #ifndef PRODUCT |
97 virtual void dump_spec(outputStream *st) const; | 98 virtual void dump_spec(outputStream *st) const; |
98 #endif | 99 #endif |
99 }; | 100 }; |
100 | 101 |
101 //------------------------------Counted Loops---------------------------------- | 102 //------------------------------Counted Loops---------------------------------- |
102 // Counted loops are all trip-counted loops, with exactly 1 trip-counter exit | 103 // Counted loops are all trip-counted loops, with exactly 1 trip-counter exit |
103 // path (and maybe some other exit paths). The trip-counter exit is always | 104 // path (and maybe some other exit paths). The trip-counter exit is always |
104 // last in the loop. The trip-counter does not have to stride by a constant, | 105 // last in the loop. The trip-counter have to stride by a constant; |
105 // but it does have to stride by a loop-invariant amount; the exit value is | 106 // the exit value is also loop invariant. |
106 // also loop invariant. | |
107 | 107 |
108 // CountedLoopNodes and CountedLoopEndNodes come in matched pairs. The | 108 // CountedLoopNodes and CountedLoopEndNodes come in matched pairs. The |
109 // CountedLoopNode has the incoming loop control and the loop-back-control | 109 // CountedLoopNode has the incoming loop control and the loop-back-control |
110 // which is always the IfTrue before the matching CountedLoopEndNode. The | 110 // which is always the IfTrue before the matching CountedLoopEndNode. The |
111 // CountedLoopEndNode has an incoming control (possibly not the | 111 // CountedLoopEndNode has an incoming control (possibly not the |
112 // CountedLoopNode if there is control flow in the loop), the post-increment | 112 // CountedLoopNode if there is control flow in the loop), the post-increment |
113 // trip-counter value, and the limit. The trip-counter value is always of | 113 // trip-counter value, and the limit. The trip-counter value is always of |
114 // the form (Op old-trip-counter stride). The old-trip-counter is produced | 114 // the form (Op old-trip-counter stride). The old-trip-counter is produced |
115 // by a Phi connected to the CountedLoopNode. The stride is loop invariant. | 115 // by a Phi connected to the CountedLoopNode. The stride is constant. |
116 // The Op is any commutable opcode, including Add, Mul, Xor. The | 116 // The Op is any commutable opcode, including Add, Mul, Xor. The |
117 // CountedLoopEndNode also takes in the loop-invariant limit value. | 117 // CountedLoopEndNode also takes in the loop-invariant limit value. |
118 | 118 |
119 // From a CountedLoopNode I can reach the matching CountedLoopEndNode via the | 119 // From a CountedLoopNode I can reach the matching CountedLoopEndNode via the |
120 // loop-back control. From CountedLoopEndNodes I can reach CountedLoopNodes | 120 // loop-back control. From CountedLoopEndNodes I can reach CountedLoopNodes |
694 void recompute_dom_depth(); | 694 void recompute_dom_depth(); |
695 | 695 |
696 // Is safept not required by an outer loop? | 696 // Is safept not required by an outer loop? |
697 bool is_deleteable_safept(Node* sfpt); | 697 bool is_deleteable_safept(Node* sfpt); |
698 | 698 |
699 // Replace parallel induction variable (parallel to trip counter) | |
700 void replace_parallel_iv(IdealLoopTree *loop); | |
701 | |
699 // Perform verification that the graph is valid. | 702 // Perform verification that the graph is valid. |
700 PhaseIdealLoop( PhaseIterGVN &igvn) : | 703 PhaseIdealLoop( PhaseIterGVN &igvn) : |
701 PhaseTransform(Ideal_Loop), | 704 PhaseTransform(Ideal_Loop), |
702 _igvn(igvn), | 705 _igvn(igvn), |
703 _dom_lca_tags(arena()), // Thread::resource_area | 706 _dom_lca_tags(arena()), // Thread::resource_area |
749 bool _has_irreducible_loops; | 752 bool _has_irreducible_loops; |
750 | 753 |
751 // Per-Node transform | 754 // Per-Node transform |
752 virtual Node *transform( Node *a_node ) { return 0; } | 755 virtual Node *transform( Node *a_node ) { return 0; } |
753 | 756 |
754 Node *is_counted_loop( Node *x, IdealLoopTree *loop ); | 757 bool is_counted_loop( Node *x, IdealLoopTree *loop ); |
755 | 758 |
756 // Return a post-walked LoopNode | 759 // Return a post-walked LoopNode |
757 IdealLoopTree *get_loop( Node *n ) const { | 760 IdealLoopTree *get_loop( Node *n ) const { |
758 // Dead nodes have no loop, so return the top level loop instead | 761 // Dead nodes have no loop, so return the top level loop instead |
759 if (!has_node(n)) return _ltree_root; | 762 if (!has_node(n)) return _ltree_root; |
813 | 816 |
814 // Return true if exp is a scaled induction var plus (or minus) constant | 817 // Return true if exp is a scaled induction var plus (or minus) constant |
815 bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0); | 818 bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0); |
816 | 819 |
817 // Return true if proj is for "proj->[region->..]call_uct" | 820 // Return true if proj is for "proj->[region->..]call_uct" |
818 bool is_uncommon_trap_proj(ProjNode* proj, bool must_reason_predicate = false); | 821 // Return true if proj is for "proj->[region->..]call_uct" |
822 static bool is_uncommon_trap_proj(ProjNode* proj, Deoptimization::DeoptReason reason); | |
819 // Return true for "if(test)-> proj -> ... | 823 // Return true for "if(test)-> proj -> ... |
820 // | | 824 // | |
821 // V | 825 // V |
822 // other_proj->[region->..]call_uct" | 826 // other_proj->[region->..]call_uct" |
823 bool is_uncommon_trap_if_pattern(ProjNode* proj, bool must_reason_predicate = false); | 827 static bool is_uncommon_trap_if_pattern(ProjNode* proj, Deoptimization::DeoptReason reason); |
824 // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted | 828 // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted |
825 ProjNode* create_new_if_for_predicate(ProjNode* cont_proj); | 829 ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, |
826 // Find a good location to insert a predicate | 830 Deoptimization::DeoptReason reason); |
827 ProjNode* find_predicate_insertion_point(Node* start_c); | 831 void register_control(Node* n, IdealLoopTree *loop, Node* pred); |
832 | |
833 // Find a good location to insert a predicate | |
834 static ProjNode* find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason); | |
835 // Find a predicate | |
836 static Node* find_predicate(Node* entry); | |
828 // Construct a range check for a predicate if | 837 // Construct a range check for a predicate if |
829 BoolNode* rc_predicate(Node* ctrl, | 838 BoolNode* rc_predicate(Node* ctrl, |
830 int scale, Node* offset, | 839 int scale, Node* offset, |
831 Node* init, Node* limit, Node* stride, | 840 Node* init, Node* limit, Node* stride, |
832 Node* range, bool upper); | 841 Node* range, bool upper); |
934 Node *split_if_with_blocks_pre ( Node *n ); | 943 Node *split_if_with_blocks_pre ( Node *n ); |
935 void split_if_with_blocks_post( Node *n ); | 944 void split_if_with_blocks_post( Node *n ); |
936 Node *has_local_phi_input( Node *n ); | 945 Node *has_local_phi_input( Node *n ); |
937 // Mark an IfNode as being dominated by a prior test, | 946 // Mark an IfNode as being dominated by a prior test, |
938 // without actually altering the CFG (and hence IDOM info). | 947 // without actually altering the CFG (and hence IDOM info). |
939 void dominated_by( Node *prevdom, Node *iff ); | 948 void dominated_by( Node *prevdom, Node *iff, bool flip = false ); |
940 | 949 |
941 // Split Node 'n' through merge point | 950 // Split Node 'n' through merge point |
942 Node *split_thru_region( Node *n, Node *region ); | 951 Node *split_thru_region( Node *n, Node *region ); |
943 // Split Node 'n' through merge point if there is enough win. | 952 // Split Node 'n' through merge point if there is enough win. |
944 Node *split_thru_phi( Node *n, Node *region, int policy ); | 953 Node *split_thru_phi( Node *n, Node *region, int policy ); |