< prev index next >

src/hotspot/share/opto/loopnode.hpp

Print this page

  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 LoopSelector;
  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:

  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          MultiversionFastLoop         = 1<<17,
  85          MultiversionSlowLoop         = 2<<17,
  86          MultiversionDelayedSlowLoop  = 3<<17,
  87          MultiversionFlagsMask        = 3<<17,
  88        };
  89   char _unswitch_count;
  90   enum { _unswitch_max=3 };
  91 
  92   // Expected trip count from profile data
  93   float _profile_trip_cnt;
  94 
  95 public:
  96   // Names for edge indices
  97   enum { Self=0, EntryControl, LoopBackControl };
  98 
  99   bool is_inner_loop() const { return _loop_flags & InnerLoop; }
 100   void set_inner_loop() { _loop_flags |= InnerLoop; }
 101 
 102   bool is_vectorized_loop() const { return _loop_flags & VectorizedLoop; }
 103   bool is_partial_peel_loop() const { return _loop_flags & PartialPeelLoop; }
 104   void set_partial_peel_loop() { _loop_flags |= PartialPeelLoop; }
 105   bool partial_peel_has_failed() const { return _loop_flags & PartialPeelFailed; }
 106   bool is_strip_mined() const { return _loop_flags & StripMined; }
 107   bool is_profile_trip_failed() const { return _loop_flags & ProfileTripFailed; }
 108   bool is_subword_loop() const { return _loop_flags & SubwordLoop; }
 109   bool is_loop_nest_inner_loop() const { return _loop_flags & LoopNestInnerLoop; }
 110   bool is_loop_nest_outer_loop() const { return _loop_flags & LoopNestLongOuterLoop; }

 111 
 112   void mark_partial_peel_failed() { _loop_flags |= PartialPeelFailed; }
 113   void mark_was_slp() { _loop_flags |= WasSlpAnalyzed; }
 114   void mark_passed_slp() { _loop_flags |= PassedSlpAnalysis; }
 115   void mark_do_unroll_only() { _loop_flags |= DoUnrollOnly; }
 116   void mark_loop_vectorized() { _loop_flags |= VectorizedLoop; }
 117   void mark_has_atomic_post_loop() { _loop_flags |= HasAtomicPostLoop; }
 118   void mark_strip_mined() { _loop_flags |= StripMined; }
 119   void clear_strip_mined() { _loop_flags &= ~StripMined; }
 120   void mark_profile_trip_failed() { _loop_flags |= ProfileTripFailed; }
 121   void mark_subword_loop() { _loop_flags |= SubwordLoop; }
 122   void mark_loop_nest_inner_loop() { _loop_flags |= LoopNestInnerLoop; }
 123   void mark_loop_nest_outer_loop() { _loop_flags |= LoopNestLongOuterLoop; }

 124 
 125   int unswitch_max() { return _unswitch_max; }
 126   int unswitch_count() { return _unswitch_count; }
 127 
 128   void set_unswitch_count(int val) {
 129     assert (val <= unswitch_max(), "too many unswitches");
 130     _unswitch_count = val;
 131   }
 132 
 133   void set_profile_trip_cnt(float ptc) { _profile_trip_cnt = ptc; }
 134   float profile_trip_cnt()             { return _profile_trip_cnt; }
 135 
 136 #ifndef PRODUCT
 137   uint _stress_peeling_attempts = 0;
 138 #endif
 139 
 140   LoopNode(Node *entry, Node *backedge)
 141     : RegionNode(3), _loop_flags(0), _unswitch_count(0),
 142       _profile_trip_cnt(COUNT_UNKNOWN) {
 143     init_class_id(Class_Loop);

 717   // Convert to counted loops where possible
 718   void counted_loop( PhaseIdealLoop *phase );
 719 
 720   // Check for Node being a loop-breaking test
 721   Node *is_loop_exit(Node *iff) const;
 722 
 723   // Remove simplistic dead code from loop body
 724   void DCE_loop_body();
 725 
 726   // Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
 727   // Replace with a 1-in-10 exit guess.
 728   void adjust_loop_exit_prob( PhaseIdealLoop *phase );
 729 
 730   // Return TRUE or FALSE if the loop should never be RCE'd or aligned.
 731   // Useful for unrolling loops with NO array accesses.
 732   bool policy_peel_only( PhaseIdealLoop *phase ) const;
 733 
 734   // Return TRUE or FALSE if the loop should be unswitched -- clone
 735   // loop with an invariant test
 736   bool policy_unswitching( PhaseIdealLoop *phase ) const;

 737 
 738   // Micro-benchmark spamming.  Remove empty loops.
 739   bool do_remove_empty_loop( PhaseIdealLoop *phase );
 740 
 741   // Convert one-iteration loop into normal code.
 742   bool do_one_iteration_loop( PhaseIdealLoop *phase );
 743 
 744   // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can
 745   // move some loop-invariant test (usually a null-check) before the loop.
 746   bool policy_peeling(PhaseIdealLoop *phase);
 747 
 748   uint estimate_peeling(PhaseIdealLoop *phase);
 749 
 750   // Return TRUE or FALSE if the loop should be maximally unrolled. Stash any
 751   // known trip count in the counted loop node.
 752   bool policy_maximally_unroll(PhaseIdealLoop *phase) const;
 753 
 754   // Return TRUE or FALSE if the loop should be unrolled or not. Apply unroll
 755   // if the loop is a counted loop and the loop body is small enough.
 756   bool policy_unroll(PhaseIdealLoop *phase);

1620 
1621  public:
1622   // Change the control input of expensive nodes to allow commoning by
1623   // IGVN when it is guaranteed to not result in a more frequent
1624   // execution of the expensive node. Return true if progress.
1625   bool process_expensive_nodes();
1626 
1627   // Check whether node has become unreachable
1628   bool is_node_unreachable(Node *n) const {
1629     return !has_node(n) || n->is_unreachable(_igvn);
1630   }
1631 
1632   // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1633   void do_range_check(IdealLoopTree* loop);
1634 
1635   // Clone loop with an invariant test (that does not exit) and
1636   // insert a clone of the test that selects which version to
1637   // execute.
1638   void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1639 
1640   IfNode* find_unswitch_candidate(const IdealLoopTree* loop) const;

1641 
1642  private:
1643   static bool has_control_dependencies_from_predicates(LoopNode* head);
1644   static void revert_to_normal_loop(const LoopNode* loop_head);
1645 
1646   void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1647                                    const UnswitchedLoopSelector& unswitched_loop_selector);
1648   void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1649   static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1650   void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1651 #ifndef PRODUCT
1652   static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1653   static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1654   static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,

1655                                             const LoopNode* original_head, const LoopNode* new_head);
1656   static void trace_loop_multiversioning_result(const LoopSelector& loop_selector,
1657                                                 const LoopNode* original_head, const LoopNode* new_head);
1658 #endif
1659 
1660  public:
1661 
1662   // Range Check Elimination uses this function!
1663   // Constrain the main loop iterations so the affine function:
1664   //    low_limit <= scale_con * I + offset  <  upper_limit
1665   // always holds true.  That is, either increase the number of iterations in
1666   // the pre-loop or the post-loop until the condition holds true in the main
1667   // loop.  Scale_con, offset and limit are all loop invariant.
1668   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);
1669   // Helper function for add_constraint().
1670   Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1671 
1672   // Partially peel loop up through last_peel node.
1673   bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1674   bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);

1826   void split_thru_phi_yank_old_nodes(Node* n, Node* region);
1827 
1828 public:
1829 
1830   // Conversion of fill/copy patterns into intrinsic versions
1831   bool do_intrinsify_fill();
1832   bool intrinsify_fill(IdealLoopTree* lpt);
1833   bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1834                        Node*& shift, Node*& offset);
1835 
1836 private:
1837   // Helper functions
1838   Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1839   Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1840   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 );
1841   bool split_up( Node *n, Node *blk1, Node *blk2 );
1842 
1843   Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1844   Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1845   void try_move_store_after_loop(Node* n);

1846   bool identical_backtoback_ifs(Node *n);

1847   bool can_split_if(Node *n_ctrl);
1848   bool cannot_split_division(const Node* n, const Node* region) const;
1849   static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1850   bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1851 
1852   // Determine if a method is too big for a/another round of split-if, based on
1853   // a magic (approximate) ratio derived from the equally magic constant 35000,
1854   // previously used for this purpose (but without relating to the node limit).
1855   bool must_throttle_split_if() {
1856     uint threshold = C->max_node_limit() * 2 / 5;
1857     return C->live_nodes() > threshold;
1858   }
1859 
1860   // A simplistic node request tracking mechanism, where
1861   //   = UINT_MAX   Request not valid or made final.
1862   //   < UINT_MAX   Nodes currently requested (estimate).
1863   uint _nodes_required;
1864 
1865   enum { REQUIRE_MIN = 70 };
1866 

2017                      uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
2018                      Node_List*& split_bool_set, Node_List*& split_cex_set);
2019 
2020   void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
2021 
2022   bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
2023 
2024   bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
2025   void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
2026   bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
2027   void clone_template_assertion_expression_down(Node* node);
2028 
2029   Node* similar_subtype_check(const Node* x, Node* r_in);
2030 
2031   void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
2032 
2033   bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
2034 
2035   void pin_nodes_dependent_on(Node* ctrl, bool old_iff_is_rangecheck);
2036 


2037   Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
2038 
2039   Node* new_assertion_predicate_opaque_init(Node* entry_control, Node* init, Node* int_zero);
2040 
2041   bool try_make_short_running_loop(IdealLoopTree* loop, jint stride_con, const Node_List& range_checks, const uint iters_limit);
2042 
2043   ConINode* intcon(jint i);
2044 
2045   ConLNode* longcon(jlong i);
2046 
2047   ConNode* makecon(const Type* t);
2048 
2049   ConNode* integercon(jlong l, BasicType bt);
2050 
2051   ConNode* zerocon(BasicType bt);
2052 };
2053 
2054 class CountedLoopConverter {
2055   friend class PhaseIdealLoop;
2056 

  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 LoopSelector;
  48 class UnswitchedLoopSelector;
  49 class VectorSet;
  50 class VSharedData;
  51 class Invariance;
  52 struct small_cache;
  53 
  54 //
  55 //                  I D E A L I Z E D   L O O P S
  56 //
  57 // Idealized loops are the set of loops I perform more interesting
  58 // transformations on, beyond simple hoisting.
  59 
  60 //------------------------------LoopNode---------------------------------------
  61 // Simple loop header.  Fall in path on left, loop-back path on right.
  62 class LoopNode : public RegionNode {
  63   // Size is bigger to hold the flags.  However, the flags do not change
  64   // the semantics so it does not appear in the hash & cmp functions.
  65   virtual uint size_of() const { return sizeof(*this); }
  66 protected:

  69   enum { Normal=0, Pre=1, Main=2, Post=3, PreMainPostFlagsMask=3,
  70          MainHasNoPreLoop      = 1<<2,
  71          HasExactTripCount     = 1<<3,
  72          InnerLoop             = 1<<4,
  73          PartialPeelLoop       = 1<<5,
  74          PartialPeelFailed     = 1<<6,
  75          WasSlpAnalyzed        = 1<<7,
  76          PassedSlpAnalysis     = 1<<8,
  77          DoUnrollOnly          = 1<<9,
  78          VectorizedLoop        = 1<<10,
  79          HasAtomicPostLoop     = 1<<11,
  80          StripMined            = 1<<12,
  81          SubwordLoop           = 1<<13,
  82          ProfileTripFailed     = 1<<14,
  83          LoopNestInnerLoop     = 1<<15,
  84          LoopNestLongOuterLoop = 1<<16,
  85          MultiversionFastLoop         = 1<<17,
  86          MultiversionSlowLoop         = 2<<17,
  87          MultiversionDelayedSlowLoop  = 3<<17,
  88          MultiversionFlagsMask        = 3<<17,
  89          FlatArrays            = 1<<18};
  90   char _unswitch_count;
  91   enum { _unswitch_max=3 };
  92 
  93   // Expected trip count from profile data
  94   float _profile_trip_cnt;
  95 
  96 public:
  97   // Names for edge indices
  98   enum { Self=0, EntryControl, LoopBackControl };
  99 
 100   bool is_inner_loop() const { return _loop_flags & InnerLoop; }
 101   void set_inner_loop() { _loop_flags |= InnerLoop; }
 102 
 103   bool is_vectorized_loop() const { return _loop_flags & VectorizedLoop; }
 104   bool is_partial_peel_loop() const { return _loop_flags & PartialPeelLoop; }
 105   void set_partial_peel_loop() { _loop_flags |= PartialPeelLoop; }
 106   bool partial_peel_has_failed() const { return _loop_flags & PartialPeelFailed; }
 107   bool is_strip_mined() const { return _loop_flags & StripMined; }
 108   bool is_profile_trip_failed() const { return _loop_flags & ProfileTripFailed; }
 109   bool is_subword_loop() const { return _loop_flags & SubwordLoop; }
 110   bool is_loop_nest_inner_loop() const { return _loop_flags & LoopNestInnerLoop; }
 111   bool is_loop_nest_outer_loop() const { return _loop_flags & LoopNestLongOuterLoop; }
 112   bool is_flat_arrays() const { return _loop_flags & FlatArrays; }
 113 
 114   void mark_partial_peel_failed() { _loop_flags |= PartialPeelFailed; }
 115   void mark_was_slp() { _loop_flags |= WasSlpAnalyzed; }
 116   void mark_passed_slp() { _loop_flags |= PassedSlpAnalysis; }
 117   void mark_do_unroll_only() { _loop_flags |= DoUnrollOnly; }
 118   void mark_loop_vectorized() { _loop_flags |= VectorizedLoop; }
 119   void mark_has_atomic_post_loop() { _loop_flags |= HasAtomicPostLoop; }
 120   void mark_strip_mined() { _loop_flags |= StripMined; }
 121   void clear_strip_mined() { _loop_flags &= ~StripMined; }
 122   void mark_profile_trip_failed() { _loop_flags |= ProfileTripFailed; }
 123   void mark_subword_loop() { _loop_flags |= SubwordLoop; }
 124   void mark_loop_nest_inner_loop() { _loop_flags |= LoopNestInnerLoop; }
 125   void mark_loop_nest_outer_loop() { _loop_flags |= LoopNestLongOuterLoop; }
 126   void mark_flat_arrays() { _loop_flags |= FlatArrays; }
 127 
 128   int unswitch_max() { return _unswitch_max; }
 129   int unswitch_count() { return _unswitch_count; }
 130 
 131   void set_unswitch_count(int val) {
 132     assert (val <= unswitch_max(), "too many unswitches");
 133     _unswitch_count = val;
 134   }
 135 
 136   void set_profile_trip_cnt(float ptc) { _profile_trip_cnt = ptc; }
 137   float profile_trip_cnt()             { return _profile_trip_cnt; }
 138 
 139 #ifndef PRODUCT
 140   uint _stress_peeling_attempts = 0;
 141 #endif
 142 
 143   LoopNode(Node *entry, Node *backedge)
 144     : RegionNode(3), _loop_flags(0), _unswitch_count(0),
 145       _profile_trip_cnt(COUNT_UNKNOWN) {
 146     init_class_id(Class_Loop);

 720   // Convert to counted loops where possible
 721   void counted_loop( PhaseIdealLoop *phase );
 722 
 723   // Check for Node being a loop-breaking test
 724   Node *is_loop_exit(Node *iff) const;
 725 
 726   // Remove simplistic dead code from loop body
 727   void DCE_loop_body();
 728 
 729   // Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
 730   // Replace with a 1-in-10 exit guess.
 731   void adjust_loop_exit_prob( PhaseIdealLoop *phase );
 732 
 733   // Return TRUE or FALSE if the loop should never be RCE'd or aligned.
 734   // Useful for unrolling loops with NO array accesses.
 735   bool policy_peel_only( PhaseIdealLoop *phase ) const;
 736 
 737   // Return TRUE or FALSE if the loop should be unswitched -- clone
 738   // loop with an invariant test
 739   bool policy_unswitching( PhaseIdealLoop *phase ) const;
 740   bool no_unswitch_candidate() const;
 741 
 742   // Micro-benchmark spamming.  Remove empty loops.
 743   bool do_remove_empty_loop( PhaseIdealLoop *phase );
 744 
 745   // Convert one-iteration loop into normal code.
 746   bool do_one_iteration_loop( PhaseIdealLoop *phase );
 747 
 748   // Return TRUE or FALSE if the loop should be peeled or not. Peel if we can
 749   // move some loop-invariant test (usually a null-check) before the loop.
 750   bool policy_peeling(PhaseIdealLoop *phase);
 751 
 752   uint estimate_peeling(PhaseIdealLoop *phase);
 753 
 754   // Return TRUE or FALSE if the loop should be maximally unrolled. Stash any
 755   // known trip count in the counted loop node.
 756   bool policy_maximally_unroll(PhaseIdealLoop *phase) const;
 757 
 758   // Return TRUE or FALSE if the loop should be unrolled or not. Apply unroll
 759   // if the loop is a counted loop and the loop body is small enough.
 760   bool policy_unroll(PhaseIdealLoop *phase);

1624 
1625  public:
1626   // Change the control input of expensive nodes to allow commoning by
1627   // IGVN when it is guaranteed to not result in a more frequent
1628   // execution of the expensive node. Return true if progress.
1629   bool process_expensive_nodes();
1630 
1631   // Check whether node has become unreachable
1632   bool is_node_unreachable(Node *n) const {
1633     return !has_node(n) || n->is_unreachable(_igvn);
1634   }
1635 
1636   // Eliminate range-checks and other trip-counter vs loop-invariant tests.
1637   void do_range_check(IdealLoopTree* loop);
1638 
1639   // Clone loop with an invariant test (that does not exit) and
1640   // insert a clone of the test that selects which version to
1641   // execute.
1642   void do_unswitching(IdealLoopTree* loop, Node_List& old_new);
1643 
1644   IfNode* find_unswitch_candidates(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
1645   IfNode* find_unswitch_candidate_from_idoms(const IdealLoopTree* loop) const;
1646 
1647  private:
1648   static bool has_control_dependencies_from_predicates(LoopNode* head);
1649   static void revert_to_normal_loop(const LoopNode* loop_head);
1650 
1651   void hoist_invariant_check_casts(const IdealLoopTree* loop, const Node_List& old_new,
1652                                    const UnswitchCandidate& unswitch_candidate, const IfNode* loop_selector);
1653   void add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new);
1654   static void increment_unswitch_counts(LoopNode* original_head, LoopNode* new_head);
1655   void remove_unswitch_candidate_from_loops(const Node_List& old_new, const UnswitchedLoopSelector& unswitched_loop_selector);
1656 #ifndef PRODUCT
1657   static void trace_loop_unswitching_count(IdealLoopTree* loop, LoopNode* original_head);
1658   static void trace_loop_unswitching_impossible(const LoopNode* original_head);
1659   static void trace_loop_unswitching_result(const UnswitchedLoopSelector& unswitched_loop_selector,
1660                                             const UnswitchCandidate& unswitch_candidate,
1661                                             const LoopNode* original_head, const LoopNode* new_head);
1662   static void trace_loop_multiversioning_result(const LoopSelector& loop_selector,
1663                                                 const LoopNode* original_head, const LoopNode* new_head);
1664 #endif
1665 
1666  public:
1667 
1668   // Range Check Elimination uses this function!
1669   // Constrain the main loop iterations so the affine function:
1670   //    low_limit <= scale_con * I + offset  <  upper_limit
1671   // always holds true.  That is, either increase the number of iterations in
1672   // the pre-loop or the post-loop until the condition holds true in the main
1673   // loop.  Scale_con, offset and limit are all loop invariant.
1674   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);
1675   // Helper function for add_constraint().
1676   Node* adjust_limit(bool reduce, Node* scale, Node* offset, Node* rc_limit, Node* old_limit, Node* pre_ctrl, bool round);
1677 
1678   // Partially peel loop up through last_peel node.
1679   bool partial_peel( IdealLoopTree *loop, Node_List &old_new );
1680   bool duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old_new);

1832   void split_thru_phi_yank_old_nodes(Node* n, Node* region);
1833 
1834 public:
1835 
1836   // Conversion of fill/copy patterns into intrinsic versions
1837   bool do_intrinsify_fill();
1838   bool intrinsify_fill(IdealLoopTree* lpt);
1839   bool match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& store_value,
1840                        Node*& shift, Node*& offset);
1841 
1842 private:
1843   // Helper functions
1844   Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
1845   Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
1846   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 );
1847   bool split_up( Node *n, Node *blk1, Node *blk2 );
1848 
1849   Node* place_outside_loop(Node* useblock, IdealLoopTree* loop) const;
1850   Node* try_move_store_before_loop(Node* n, Node *n_ctrl);
1851   void try_move_store_after_loop(Node* n);
1852   void move_flat_array_check_out_of_loop(Node* n);
1853   bool identical_backtoback_ifs(Node *n);
1854   bool flat_array_element_type_check(Node *n);
1855   bool can_split_if(Node *n_ctrl);
1856   bool cannot_split_division(const Node* n, const Node* region) const;
1857   static bool is_divisor_loop_phi(const Node* divisor, const Node* loop);
1858   bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
1859 
1860   // Determine if a method is too big for a/another round of split-if, based on
1861   // a magic (approximate) ratio derived from the equally magic constant 35000,
1862   // previously used for this purpose (but without relating to the node limit).
1863   bool must_throttle_split_if() {
1864     uint threshold = C->max_node_limit() * 2 / 5;
1865     return C->live_nodes() > threshold;
1866   }
1867 
1868   // A simplistic node request tracking mechanism, where
1869   //   = UINT_MAX   Request not valid or made final.
1870   //   < UINT_MAX   Nodes currently requested (estimate).
1871   uint _nodes_required;
1872 
1873   enum { REQUIRE_MIN = 70 };
1874 

2025                      uint new_counter, Node_List& old_new, Node_List& worklist, Node_List*& split_if_set,
2026                      Node_List*& split_bool_set, Node_List*& split_cex_set);
2027 
2028   void finish_clone_loop(Node_List* split_if_set, Node_List* split_bool_set, Node_List* split_cex_set);
2029 
2030   bool at_relevant_ctrl(Node* n, const Node* blk1, const Node* blk2);
2031 
2032   bool clone_cmp_loadklass_down(Node* n, const Node* blk1, const Node* blk2);
2033   void clone_loadklass_nodes_at_cmp_index(const Node* n, Node* cmp, int i);
2034   bool clone_cmp_down(Node* n, const Node* blk1, const Node* blk2);
2035   void clone_template_assertion_expression_down(Node* node);
2036 
2037   Node* similar_subtype_check(const Node* x, Node* r_in);
2038 
2039   void update_addp_chain_base(Node* x, Node* old_base, Node* new_base);
2040 
2041   bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
2042 
2043   void pin_nodes_dependent_on(Node* ctrl, bool old_iff_is_rangecheck);
2044 
2045   void collect_flat_array_checks(const IdealLoopTree* loop, Node_List& flat_array_checks) const;
2046 
2047   Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node);
2048 
2049   Node* new_assertion_predicate_opaque_init(Node* entry_control, Node* init, Node* int_zero);
2050 
2051   bool try_make_short_running_loop(IdealLoopTree* loop, jint stride_con, const Node_List& range_checks, const uint iters_limit);
2052 
2053   ConINode* intcon(jint i);
2054 
2055   ConLNode* longcon(jlong i);
2056 
2057   ConNode* makecon(const Type* t);
2058 
2059   ConNode* integercon(jlong l, BasicType bt);
2060 
2061   ConNode* zerocon(BasicType bt);
2062 };
2063 
2064 class CountedLoopConverter {
2065   friend class PhaseIdealLoop;
2066 
< prev index next >