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);
1416
1417 public:
1418 // Change the control input of expensive nodes to allow commoning by
1419 // IGVN when it is guaranteed to not result in a more frequent
1420 // execution of the expensive node. Return true if progress.
1421 bool process_expensive_nodes();
1422
1423 // Check whether node has become unreachable
1424 bool is_node_unreachable(Node *n) const {
1425 return !has_node(n) || n->is_unreachable(_igvn);
1426 }
1427
1428 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1429 void do_range_check(IdealLoopTree *loop, Node_List &old_new);
1430
1431 // Clone loop with an invariant test (that does not exit) and
1432 // insert a clone of the test that selects which version to
1433 // execute.
1434 void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1435
1436 IfNode* find_unswitch_candidate(const IdealLoopTree* loop) const;
1437
1438 private:
1439 static bool has_control_dependencies_from_predicates(LoopNode* head);
1440 static void revert_to_normal_loop(const LoopNode* loop_head);
1441
1442 void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1443 const UnswitchedLoopSelector& unswitched_loop_selector);
1444 void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1445 static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1446 void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1447 #ifndef PRODUCT
1448 static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1449 static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1450 static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,
1451 const LoopNode* original_head, const LoopNode* new_head);
1452 #endif
1453
1454 public:
1455
1456 // Range Check Elimination uses this function!
1457 // Constrain the main loop iterations so the affine function:
1458 // low_limit <= scale_con * I + offset < upper_limit
1459 // always holds true. That is, either increase the number of iterations in
1460 // the pre-loop or the post-loop until the condition holds true in the main
1461 // loop. Scale_con, offset and limit are all loop invariant.
1462 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);
1463 // Helper function for add_constraint().
1464 Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1465
1466 // Partially peel loop up through last_peel node.
1467 bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1468 bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);
1469
1470 // AutoVectorize the loop: replace scalar ops with vector ops.
1565 bool intrinsify_fill(IdealLoopTree* lpt);
1566 bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1567 Node*& shift, Node*& offset);
1568
1569 private:
1570 // Return a type based on condition control flow
1571 const TypeInt* filtered_type( Node *n, Node* n_ctrl);
1572 const TypeInt* filtered_type( Node *n ) { return filtered_type(n, nullptr); }
1573 // Helpers for filtered type
1574 const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl);
1575
1576 // Helper functions
1577 Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1578 Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1579 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 );
1580 bool split_up( Node *n, Node *blk1, Node *blk2 );
1581
1582 Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1583 Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1584 void try_move_store_after_loop(Node* n);
1585 bool identical_backtoback_ifs(Node *n);
1586 bool can_split_if(Node *n_ctrl);
1587 bool cannot_split_division(const Node* n, const Node* region) const;
1588 static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1589 bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1590
1591 // Determine if a method is too big for a/another round of split-if, based on
1592 // a magic (approximate) ratio derived from the equally magic constant 35000,
1593 // previously used for this purpose (but without relating to the node limit).
1594 bool must_throttle_split_if() {
1595 uint threshold = C->max_node_limit() * 2 / 5;
1596 return C->live_nodes() > threshold;
1597 }
1598
1599 // A simplistic node request tracking mechanism, where
1600 // = UINT_MAX Request not valid or made final.
1601 // < UINT_MAX Nodes currently requested (estimate).
1602 uint _nodes_required;
1603
1604 enum { REQUIRE_MIN = 70 };
1605
1775 uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
1776 Node_List*& split_bool_set, Node_List*& split_cex_set);
1777
1778 void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
1779
1780 bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
1781
1782 bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
1783 void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
1784 bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
1785 void clone_template_assertion_expression_down(Node* node);
1786
1787 Node* similar_subtype_check(const Node* x, Node* r_in);
1788
1789 void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
1790
1791 bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
1792
1793 void pin_array_access_nodes_dependent_on(Node* ctrl);
1794
1795 Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
1796 };
1797
1798
1799 class AutoNodeBudget : public StackObj
1800 {
1801 public:
1802 enum budget_check_t { BUDGET_CHECK, NO_BUDGET_CHECK };
1803
1804 AutoNodeBudget(PhaseIdealLoop* phase, budget_check_t chk = BUDGET_CHECK)
1805 : _phase(phase),
1806 _check_at_final(chk == BUDGET_CHECK),
1807 _nodes_at_begin(0)
1808 {
1809 precond(_phase != nullptr);
1810
1811 _nodes_at_begin = _phase->require_nodes_begin();
1812 }
1813
1814 ~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);
1421
1422 public:
1423 // Change the control input of expensive nodes to allow commoning by
1424 // IGVN when it is guaranteed to not result in a more frequent
1425 // execution of the expensive node. Return true if progress.
1426 bool process_expensive_nodes();
1427
1428 // Check whether node has become unreachable
1429 bool is_node_unreachable(Node *n) const {
1430 return !has_node(n) || n->is_unreachable(_igvn);
1431 }
1432
1433 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1434 void do_range_check(IdealLoopTree *loop, Node_List &old_new);
1435
1436 // Clone loop with an invariant test (that does not exit) and
1437 // insert a clone of the test that selects which version to
1438 // execute.
1439 void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1440
1441 IfNode* find_unswitch_candidates(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
1442 IfNode* find_unswitch_candidate_from_idoms(const IdealLoopTree* loop) const;
1443
1444 private:
1445 static bool has_control_dependencies_from_predicates(LoopNode* head);
1446 static void revert_to_normal_loop(const LoopNode* loop_head);
1447
1448 void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1449 const UnswitchCandidate& unswitch_candidate, const IfNode* loop_selector);
1450 void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1451 static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1452 void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1453 #ifndef PRODUCT
1454 static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1455 static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1456 static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,
1457 const UnswitchCandidate& unswitch_candidate,
1458 const LoopNode* original_head, const LoopNode* new_head);
1459 #endif
1460
1461 public:
1462
1463 // Range Check Elimination uses this function!
1464 // Constrain the main loop iterations so the affine function:
1465 // low_limit <= scale_con * I + offset < upper_limit
1466 // always holds true. That is, either increase the number of iterations in
1467 // the pre-loop or the post-loop until the condition holds true in the main
1468 // loop. Scale_con, offset and limit are all loop invariant.
1469 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);
1470 // Helper function for add_constraint().
1471 Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1472
1473 // Partially peel loop up through last_peel node.
1474 bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1475 bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);
1476
1477 // AutoVectorize the loop: replace scalar ops with vector ops.
1572 bool intrinsify_fill(IdealLoopTree* lpt);
1573 bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1574 Node*& shift, Node*& offset);
1575
1576 private:
1577 // Return a type based on condition control flow
1578 const TypeInt* filtered_type( Node *n, Node* n_ctrl);
1579 const TypeInt* filtered_type( Node *n ) { return filtered_type(n, nullptr); }
1580 // Helpers for filtered type
1581 const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl);
1582
1583 // Helper functions
1584 Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1585 Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1586 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 );
1587 bool split_up( Node *n, Node *blk1, Node *blk2 );
1588
1589 Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1590 Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1591 void try_move_store_after_loop(Node* n);
1592 void move_flat_array_check_out_of_loop(Node* n);
1593 bool identical_backtoback_ifs(Node *n);
1594 bool flat_array_element_type_check(Node *n);
1595 bool can_split_if(Node *n_ctrl);
1596 bool cannot_split_division(const Node* n, const Node* region) const;
1597 static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1598 bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1599
1600 // Determine if a method is too big for a/another round of split-if, based on
1601 // a magic (approximate) ratio derived from the equally magic constant 35000,
1602 // previously used for this purpose (but without relating to the node limit).
1603 bool must_throttle_split_if() {
1604 uint threshold = C->max_node_limit() * 2 / 5;
1605 return C->live_nodes() > threshold;
1606 }
1607
1608 // A simplistic node request tracking mechanism, where
1609 // = UINT_MAX Request not valid or made final.
1610 // < UINT_MAX Nodes currently requested (estimate).
1611 uint _nodes_required;
1612
1613 enum { REQUIRE_MIN = 70 };
1614
1784 uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
1785 Node_List*& split_bool_set, Node_List*& split_cex_set);
1786
1787 void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
1788
1789 bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
1790
1791 bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
1792 void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
1793 bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
1794 void clone_template_assertion_expression_down(Node* node);
1795
1796 Node* similar_subtype_check(const Node* x, Node* r_in);
1797
1798 void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
1799
1800 bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
1801
1802 void pin_array_access_nodes_dependent_on(Node* ctrl);
1803
1804 void collect_flat_array_checks(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
1805
1806 Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
1807 };
1808
1809
1810 class AutoNodeBudget : public StackObj
1811 {
1812 public:
1813 enum budget_check_t { BUDGET_CHECK, NO_BUDGET_CHECK };
1814
1815 AutoNodeBudget(PhaseIdealLoop* phase, budget_check_t chk = BUDGET_CHECK)
1816 : _phase(phase),
1817 _check_at_final(chk == BUDGET_CHECK),
1818 _nodes_at_begin(0)
1819 {
1820 precond(_phase != nullptr);
1821
1822 _nodes_at_begin = _phase->require_nodes_begin();
1823 }
1824
1825 ~AutoNodeBudget() {
|