26 #define SHARE_OPTO_LOOPNODE_HPP
27
28 #include "opto/cfgnode.hpp"
29 #include "opto/multnode.hpp"
30 #include "opto/phaseX.hpp"
31 #include "opto/predicates.hpp"
32 #include "opto/subnode.hpp"
33 #include "opto/type.hpp"
34 #include "utilities/checkedCast.hpp"
35
36 class CmpNode;
37 class BaseCountedLoopEndNode;
38 class CountedLoopNode;
39 class IdealLoopTree;
40 class LoopNode;
41 class Node;
42 class OuterStripMinedLoopEndNode;
43 class PredicateBlock;
44 class PathFrequency;
45 class PhaseIdealLoop;
46 class UnswitchedLoopSelector;
47 class VectorSet;
48 class VSharedData;
49 class Invariance;
50 struct small_cache;
51
52 //
53 // I D E A L I Z E D L O O P S
54 //
55 // Idealized loops are the set of loops I perform more interesting
56 // transformations on, beyond simple hoisting.
57
58 //------------------------------LoopNode---------------------------------------
59 // Simple loop header. Fall in path on left, loop-back path on right.
60 class LoopNode : public RegionNode {
61 // Size is bigger to hold the flags. However, the flags do not change
62 // the semantics so it does not appear in the hash & cmp functions.
63 virtual uint size_of() const { return sizeof(*this); }
64 protected:
65 uint _loop_flags;
66 // Names for flag bitfields
67 enum { Normal=0, Pre=1, Main=2, Post=3, PreMainPostFlagsMask=3,
68 MainHasNoPreLoop = 1<<2,
69 HasExactTripCount = 1<<3,
70 InnerLoop = 1<<4,
71 PartialPeelLoop = 1<<5,
72 PartialPeelFailed = 1<<6,
73 WasSlpAnalyzed = 1<<7,
74 PassedSlpAnalysis = 1<<8,
75 DoUnrollOnly = 1<<9,
76 VectorizedLoop = 1<<10,
77 HasAtomicPostLoop = 1<<11,
78 StripMined = 1<<12,
79 SubwordLoop = 1<<13,
80 ProfileTripFailed = 1<<14,
81 LoopNestInnerLoop = 1<<15,
82 LoopNestLongOuterLoop = 1<<16 };
83 char _unswitch_count;
84 enum { _unswitch_max=3 };
85
86 // Expected trip count from profile data
87 float _profile_trip_cnt;
88
89 public:
90 // Names for edge indices
91 enum { Self=0, EntryControl, LoopBackControl };
92
93 bool is_inner_loop() const { return _loop_flags & InnerLoop; }
94 void set_inner_loop() { _loop_flags |= InnerLoop; }
95
96 bool is_vectorized_loop() const { return _loop_flags & VectorizedLoop; }
97 bool is_partial_peel_loop() const { return _loop_flags & PartialPeelLoop; }
98 void set_partial_peel_loop() { _loop_flags |= PartialPeelLoop; }
99 bool partial_peel_has_failed() const { return _loop_flags & PartialPeelFailed; }
100 bool is_strip_mined() const { return _loop_flags & StripMined; }
101 bool is_profile_trip_failed() const { return _loop_flags & ProfileTripFailed; }
102 bool is_subword_loop() const { return _loop_flags & SubwordLoop; }
103 bool is_loop_nest_inner_loop() const { return _loop_flags & LoopNestInnerLoop; }
104 bool is_loop_nest_outer_loop() const { return _loop_flags & LoopNestLongOuterLoop; }
105
106 void mark_partial_peel_failed() { _loop_flags |= PartialPeelFailed; }
107 void mark_was_slp() { _loop_flags |= WasSlpAnalyzed; }
108 void mark_passed_slp() { _loop_flags |= PassedSlpAnalysis; }
109 void mark_do_unroll_only() { _loop_flags |= DoUnrollOnly; }
110 void mark_loop_vectorized() { _loop_flags |= VectorizedLoop; }
111 void mark_has_atomic_post_loop() { _loop_flags |= HasAtomicPostLoop; }
112 void mark_strip_mined() { _loop_flags |= StripMined; }
113 void clear_strip_mined() { _loop_flags &= ~StripMined; }
114 void mark_profile_trip_failed() { _loop_flags |= ProfileTripFailed; }
115 void mark_subword_loop() { _loop_flags |= SubwordLoop; }
116 void mark_loop_nest_inner_loop() { _loop_flags |= LoopNestInnerLoop; }
117 void mark_loop_nest_outer_loop() { _loop_flags |= LoopNestLongOuterLoop; }
118
119 int unswitch_max() { return _unswitch_max; }
120 int unswitch_count() { return _unswitch_count; }
121
122 void set_unswitch_count(int val) {
123 assert (val <= unswitch_max(), "too many unswitches");
124 _unswitch_count = val;
125 }
126
127 void set_profile_trip_cnt(float ptc) { _profile_trip_cnt = ptc; }
128 float profile_trip_cnt() { return _profile_trip_cnt; }
129
130 LoopNode(Node *entry, Node *backedge)
131 : RegionNode(3), _loop_flags(0), _unswitch_count(0),
132 _profile_trip_cnt(COUNT_UNKNOWN) {
133 init_class_id(Class_Loop);
134 init_req(EntryControl, entry);
135 init_req(LoopBackControl, backedge);
136 }
137
673 // Convert to counted loops where possible
674 void counted_loop( PhaseIdealLoop *phase );
675
676 // Check for Node being a loop-breaking test
677 Node *is_loop_exit(Node *iff) const;
678
679 // Remove simplistic dead code from loop body
680 void DCE_loop_body();
681
682 // Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
683 // Replace with a 1-in-10 exit guess.
684 void adjust_loop_exit_prob( PhaseIdealLoop *phase );
685
686 // Return TRUE or FALSE if the loop should never be RCE'd or aligned.
687 // Useful for unrolling loops with NO array accesses.
688 bool policy_peel_only( PhaseIdealLoop *phase ) const;
689
690 // Return TRUE or FALSE if the loop should be unswitched -- clone
691 // loop with an invariant test
692 bool policy_unswitching( PhaseIdealLoop *phase ) const;
693
694 // Micro-benchmark spamming. Remove empty loops.
695 bool do_remove_empty_loop( PhaseIdealLoop *phase );
696
697 // Convert one iteration loop into normal code.
698 bool do_one_iteration_loop( PhaseIdealLoop *phase );
699
700 // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can
701 // move some loop-invariant test (usually a null-check) before the loop.
702 bool policy_peeling(PhaseIdealLoop *phase);
703
704 uint estimate_peeling(PhaseIdealLoop *phase);
705
706 // Return TRUE or FALSE if the loop should be maximally unrolled. Stash any
707 // known trip count in the counted loop node.
708 bool policy_maximally_unroll(PhaseIdealLoop *phase) const;
709
710 // Return TRUE or FALSE if the loop should be unrolled or not. Apply unroll
711 // if the loop is a counted loop and the loop body is small enough.
712 bool policy_unroll(PhaseIdealLoop *phase);
1413
1414 public:
1415 // Change the control input of expensive nodes to allow commoning by
1416 // IGVN when it is guaranteed to not result in a more frequent
1417 // execution of the expensive node. Return true if progress.
1418 bool process_expensive_nodes();
1419
1420 // Check whether node has become unreachable
1421 bool is_node_unreachable(Node *n) const {
1422 return !has_node(n) || n->is_unreachable(_igvn);
1423 }
1424
1425 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1426 void do_range_check(IdealLoopTree *loop, Node_List &old_new);
1427
1428 // Clone loop with an invariant test (that does not exit) and
1429 // insert a clone of the test that selects which version to
1430 // execute.
1431 void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1432
1433 IfNode* find_unswitch_candidate(const IdealLoopTree* loop) const;
1434
1435 private:
1436 static bool has_control_dependencies_from_predicates(LoopNode* head);
1437 static void revert_to_normal_loop(const LoopNode* loop_head);
1438
1439 void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1440 const UnswitchedLoopSelector& unswitched_loop_selector);
1441 void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1442 static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1443 void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1444 #ifndef PRODUCT
1445 static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1446 static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1447 static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,
1448 const LoopNode* original_head, const LoopNode* new_head);
1449 #endif
1450
1451 public:
1452
1453 // Range Check Elimination uses this function!
1454 // Constrain the main loop iterations so the affine function:
1455 // low_limit <= scale_con * I + offset < upper_limit
1456 // always holds true. That is, either increase the number of iterations in
1457 // the pre-loop or the post-loop until the condition holds true in the main
1458 // loop. Scale_con, offset and limit are all loop invariant.
1459 void add_constraint(jlong stride_con, jlong scale_con, Node* offset, Node* low_limit, Node* upper_limit, Node* pre_ctrl, Node** pre_limit, Node** main_limit);
1460 // Helper function for add_constraint().
1461 Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1462
1463 // Partially peel loop up through last_peel node.
1464 bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1465 bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);
1466
1467 // AutoVectorize the loop: replace scalar ops with vector ops.
1562 bool intrinsify_fill(IdealLoopTree* lpt);
1563 bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1564 Node*& shift, Node*& offset);
1565
1566 private:
1567 // Return a type based on condition control flow
1568 const TypeInt* filtered_type( Node *n, Node* n_ctrl);
1569 const TypeInt* filtered_type( Node *n ) { return filtered_type(n, nullptr); }
1570 // Helpers for filtered type
1571 const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl);
1572
1573 // Helper functions
1574 Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1575 Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1576 void handle_use( Node *use, Node *def, small_cache *cache, Node *region_dom, Node *new_false, Node *new_true, Node *old_false, Node *old_true );
1577 bool split_up( Node *n, Node *blk1, Node *blk2 );
1578
1579 Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1580 Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1581 void try_move_store_after_loop(Node* n);
1582 bool identical_backtoback_ifs(Node *n);
1583 bool can_split_if(Node *n_ctrl);
1584 bool cannot_split_division(const Node* n, const Node* region) const;
1585 static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1586 bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1587
1588 // Determine if a method is too big for a/another round of split-if, based on
1589 // a magic (approximate) ratio derived from the equally magic constant 35000,
1590 // previously used for this purpose (but without relating to the node limit).
1591 bool must_throttle_split_if() {
1592 uint threshold = C->max_node_limit() * 2 / 5;
1593 return C->live_nodes() > threshold;
1594 }
1595
1596 // A simplistic node request tracking mechanism, where
1597 // = UINT_MAX Request not valid or made final.
1598 // < UINT_MAX Nodes currently requested (estimate).
1599 uint _nodes_required;
1600
1601 enum { REQUIRE_MIN = 70 };
1602
1772 uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
1773 Node_List*& split_bool_set, Node_List*& split_cex_set);
1774
1775 void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
1776
1777 bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
1778
1779 bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
1780 void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
1781 bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
1782 void clone_template_assertion_expression_down(Node* node);
1783
1784 Node* similar_subtype_check(const Node* x, Node* r_in);
1785
1786 void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
1787
1788 bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
1789
1790 void pin_array_access_nodes_dependent_on(Node* ctrl);
1791
1792 Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
1793 };
1794
1795
1796 class AutoNodeBudget : public StackObj
1797 {
1798 public:
1799 enum budget_check_t { BUDGET_CHECK, NO_BUDGET_CHECK };
1800
1801 AutoNodeBudget(PhaseIdealLoop* phase, budget_check_t chk = BUDGET_CHECK)
1802 : _phase(phase),
1803 _check_at_final(chk == BUDGET_CHECK),
1804 _nodes_at_begin(0)
1805 {
1806 precond(_phase != nullptr);
1807
1808 _nodes_at_begin = _phase->require_nodes_begin();
1809 }
1810
1811 ~AutoNodeBudget() {
|
26 #define SHARE_OPTO_LOOPNODE_HPP
27
28 #include "opto/cfgnode.hpp"
29 #include "opto/multnode.hpp"
30 #include "opto/phaseX.hpp"
31 #include "opto/predicates.hpp"
32 #include "opto/subnode.hpp"
33 #include "opto/type.hpp"
34 #include "utilities/checkedCast.hpp"
35
36 class CmpNode;
37 class BaseCountedLoopEndNode;
38 class CountedLoopNode;
39 class IdealLoopTree;
40 class LoopNode;
41 class Node;
42 class OuterStripMinedLoopEndNode;
43 class PredicateBlock;
44 class PathFrequency;
45 class PhaseIdealLoop;
46 class UnswitchCandidate;
47 class UnswitchedLoopSelector;
48 class VectorSet;
49 class VSharedData;
50 class Invariance;
51 struct small_cache;
52
53 //
54 // I D E A L I Z E D L O O P S
55 //
56 // Idealized loops are the set of loops I perform more interesting
57 // transformations on, beyond simple hoisting.
58
59 //------------------------------LoopNode---------------------------------------
60 // Simple loop header. Fall in path on left, loop-back path on right.
61 class LoopNode : public RegionNode {
62 // Size is bigger to hold the flags. However, the flags do not change
63 // the semantics so it does not appear in the hash & cmp functions.
64 virtual uint size_of() const { return sizeof(*this); }
65 protected:
66 uint _loop_flags;
67 // Names for flag bitfields
68 enum { Normal=0, Pre=1, Main=2, Post=3, PreMainPostFlagsMask=3,
69 MainHasNoPreLoop = 1<<2,
70 HasExactTripCount = 1<<3,
71 InnerLoop = 1<<4,
72 PartialPeelLoop = 1<<5,
73 PartialPeelFailed = 1<<6,
74 WasSlpAnalyzed = 1<<7,
75 PassedSlpAnalysis = 1<<8,
76 DoUnrollOnly = 1<<9,
77 VectorizedLoop = 1<<10,
78 HasAtomicPostLoop = 1<<11,
79 StripMined = 1<<12,
80 SubwordLoop = 1<<13,
81 ProfileTripFailed = 1<<14,
82 LoopNestInnerLoop = 1<<15,
83 LoopNestLongOuterLoop = 1<<16,
84 FlatArrays = 1<<17};
85 char _unswitch_count;
86 enum { _unswitch_max=3 };
87
88 // Expected trip count from profile data
89 float _profile_trip_cnt;
90
91 public:
92 // Names for edge indices
93 enum { Self=0, EntryControl, LoopBackControl };
94
95 bool is_inner_loop() const { return _loop_flags & InnerLoop; }
96 void set_inner_loop() { _loop_flags |= InnerLoop; }
97
98 bool is_vectorized_loop() const { return _loop_flags & VectorizedLoop; }
99 bool is_partial_peel_loop() const { return _loop_flags & PartialPeelLoop; }
100 void set_partial_peel_loop() { _loop_flags |= PartialPeelLoop; }
101 bool partial_peel_has_failed() const { return _loop_flags & PartialPeelFailed; }
102 bool is_strip_mined() const { return _loop_flags & StripMined; }
103 bool is_profile_trip_failed() const { return _loop_flags & ProfileTripFailed; }
104 bool is_subword_loop() const { return _loop_flags & SubwordLoop; }
105 bool is_loop_nest_inner_loop() const { return _loop_flags & LoopNestInnerLoop; }
106 bool is_loop_nest_outer_loop() const { return _loop_flags & LoopNestLongOuterLoop; }
107 bool is_flat_arrays() const { return _loop_flags & FlatArrays; }
108
109 void mark_partial_peel_failed() { _loop_flags |= PartialPeelFailed; }
110 void mark_was_slp() { _loop_flags |= WasSlpAnalyzed; }
111 void mark_passed_slp() { _loop_flags |= PassedSlpAnalysis; }
112 void mark_do_unroll_only() { _loop_flags |= DoUnrollOnly; }
113 void mark_loop_vectorized() { _loop_flags |= VectorizedLoop; }
114 void mark_has_atomic_post_loop() { _loop_flags |= HasAtomicPostLoop; }
115 void mark_strip_mined() { _loop_flags |= StripMined; }
116 void clear_strip_mined() { _loop_flags &= ~StripMined; }
117 void mark_profile_trip_failed() { _loop_flags |= ProfileTripFailed; }
118 void mark_subword_loop() { _loop_flags |= SubwordLoop; }
119 void mark_loop_nest_inner_loop() { _loop_flags |= LoopNestInnerLoop; }
120 void mark_loop_nest_outer_loop() { _loop_flags |= LoopNestLongOuterLoop; }
121 void mark_flat_arrays() { _loop_flags |= FlatArrays; }
122
123 int unswitch_max() { return _unswitch_max; }
124 int unswitch_count() { return _unswitch_count; }
125
126 void set_unswitch_count(int val) {
127 assert (val <= unswitch_max(), "too many unswitches");
128 _unswitch_count = val;
129 }
130
131 void set_profile_trip_cnt(float ptc) { _profile_trip_cnt = ptc; }
132 float profile_trip_cnt() { return _profile_trip_cnt; }
133
134 LoopNode(Node *entry, Node *backedge)
135 : RegionNode(3), _loop_flags(0), _unswitch_count(0),
136 _profile_trip_cnt(COUNT_UNKNOWN) {
137 init_class_id(Class_Loop);
138 init_req(EntryControl, entry);
139 init_req(LoopBackControl, backedge);
140 }
141
677 // Convert to counted loops where possible
678 void counted_loop( PhaseIdealLoop *phase );
679
680 // Check for Node being a loop-breaking test
681 Node *is_loop_exit(Node *iff) const;
682
683 // Remove simplistic dead code from loop body
684 void DCE_loop_body();
685
686 // Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
687 // Replace with a 1-in-10 exit guess.
688 void adjust_loop_exit_prob( PhaseIdealLoop *phase );
689
690 // Return TRUE or FALSE if the loop should never be RCE'd or aligned.
691 // Useful for unrolling loops with NO array accesses.
692 bool policy_peel_only( PhaseIdealLoop *phase ) const;
693
694 // Return TRUE or FALSE if the loop should be unswitched -- clone
695 // loop with an invariant test
696 bool policy_unswitching( PhaseIdealLoop *phase ) const;
697 bool no_unswitch_candidate() const;
698
699 // Micro-benchmark spamming. Remove empty loops.
700 bool do_remove_empty_loop( PhaseIdealLoop *phase );
701
702 // Convert one iteration loop into normal code.
703 bool do_one_iteration_loop( PhaseIdealLoop *phase );
704
705 // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can
706 // move some loop-invariant test (usually a null-check) before the loop.
707 bool policy_peeling(PhaseIdealLoop *phase);
708
709 uint estimate_peeling(PhaseIdealLoop *phase);
710
711 // Return TRUE or FALSE if the loop should be maximally unrolled. Stash any
712 // known trip count in the counted loop node.
713 bool policy_maximally_unroll(PhaseIdealLoop *phase) const;
714
715 // Return TRUE or FALSE if the loop should be unrolled or not. Apply unroll
716 // if the loop is a counted loop and the loop body is small enough.
717 bool policy_unroll(PhaseIdealLoop *phase);
1418
1419 public:
1420 // Change the control input of expensive nodes to allow commoning by
1421 // IGVN when it is guaranteed to not result in a more frequent
1422 // execution of the expensive node. Return true if progress.
1423 bool process_expensive_nodes();
1424
1425 // Check whether node has become unreachable
1426 bool is_node_unreachable(Node *n) const {
1427 return !has_node(n) || n->is_unreachable(_igvn);
1428 }
1429
1430 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1431 void do_range_check(IdealLoopTree *loop, Node_List &old_new);
1432
1433 // Clone loop with an invariant test (that does not exit) and
1434 // insert a clone of the test that selects which version to
1435 // execute.
1436 void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1437
1438 IfNode* find_unswitch_candidates(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
1439 IfNode* find_unswitch_candidate_from_idoms(const IdealLoopTree* loop) const;
1440
1441 private:
1442 static bool has_control_dependencies_from_predicates(LoopNode* head);
1443 static void revert_to_normal_loop(const LoopNode* loop_head);
1444
1445 void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1446 const UnswitchCandidate& unswitch_candidate, const IfNode* loop_selector);
1447 void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1448 static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1449 void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1450 #ifndef PRODUCT
1451 static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1452 static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1453 static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,
1454 const UnswitchCandidate& unswitch_candidate,
1455 const LoopNode* original_head, const LoopNode* new_head);
1456 #endif
1457
1458 public:
1459
1460 // Range Check Elimination uses this function!
1461 // Constrain the main loop iterations so the affine function:
1462 // low_limit <= scale_con * I + offset < upper_limit
1463 // always holds true. That is, either increase the number of iterations in
1464 // the pre-loop or the post-loop until the condition holds true in the main
1465 // loop. Scale_con, offset and limit are all loop invariant.
1466 void add_constraint(jlong stride_con, jlong scale_con, Node* offset, Node* low_limit, Node* upper_limit, Node* pre_ctrl, Node** pre_limit, Node** main_limit);
1467 // Helper function for add_constraint().
1468 Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1469
1470 // Partially peel loop up through last_peel node.
1471 bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1472 bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);
1473
1474 // AutoVectorize the loop: replace scalar ops with vector ops.
1569 bool intrinsify_fill(IdealLoopTree* lpt);
1570 bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1571 Node*& shift, Node*& offset);
1572
1573 private:
1574 // Return a type based on condition control flow
1575 const TypeInt* filtered_type( Node *n, Node* n_ctrl);
1576 const TypeInt* filtered_type( Node *n ) { return filtered_type(n, nullptr); }
1577 // Helpers for filtered type
1578 const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl);
1579
1580 // Helper functions
1581 Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1582 Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1583 void handle_use( Node *use, Node *def, small_cache *cache, Node *region_dom, Node *new_false, Node *new_true, Node *old_false, Node *old_true );
1584 bool split_up( Node *n, Node *blk1, Node *blk2 );
1585
1586 Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1587 Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1588 void try_move_store_after_loop(Node* n);
1589 void move_flat_array_check_out_of_loop(Node* n);
1590 bool identical_backtoback_ifs(Node *n);
1591 bool flat_array_element_type_check(Node *n);
1592 bool can_split_if(Node *n_ctrl);
1593 bool cannot_split_division(const Node* n, const Node* region) const;
1594 static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1595 bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1596
1597 // Determine if a method is too big for a/another round of split-if, based on
1598 // a magic (approximate) ratio derived from the equally magic constant 35000,
1599 // previously used for this purpose (but without relating to the node limit).
1600 bool must_throttle_split_if() {
1601 uint threshold = C->max_node_limit() * 2 / 5;
1602 return C->live_nodes() > threshold;
1603 }
1604
1605 // A simplistic node request tracking mechanism, where
1606 // = UINT_MAX Request not valid or made final.
1607 // < UINT_MAX Nodes currently requested (estimate).
1608 uint _nodes_required;
1609
1610 enum { REQUIRE_MIN = 70 };
1611
1781 uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
1782 Node_List*& split_bool_set, Node_List*& split_cex_set);
1783
1784 void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
1785
1786 bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
1787
1788 bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
1789 void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
1790 bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
1791 void clone_template_assertion_expression_down(Node* node);
1792
1793 Node* similar_subtype_check(const Node* x, Node* r_in);
1794
1795 void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
1796
1797 bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
1798
1799 void pin_array_access_nodes_dependent_on(Node* ctrl);
1800
1801 void collect_flat_array_checks(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
1802
1803 Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
1804 };
1805
1806
1807 class AutoNodeBudget : public StackObj
1808 {
1809 public:
1810 enum budget_check_t { BUDGET_CHECK, NO_BUDGET_CHECK };
1811
1812 AutoNodeBudget(PhaseIdealLoop* phase, budget_check_t chk = BUDGET_CHECK)
1813 : _phase(phase),
1814 _check_at_final(chk == BUDGET_CHECK),
1815 _nodes_at_begin(0)
1816 {
1817 precond(_phase != nullptr);
1818
1819 _nodes_at_begin = _phase->require_nodes_begin();
1820 }
1821
1822 ~AutoNodeBudget() {
|