896 // Take steps to maximally unroll the loop. Peel any odd iterations, then
897 // unroll to do double iterations. The next round of major loop transforms
898 // will repeat till the doubled loop body does all remaining iterations in 1
899 // pass.
900 void do_maximally_unroll( IdealLoopTree *loop, Node_List &old_new );
901
902 // Unroll the loop body one step - make each trip do 2 iterations.
903 void do_unroll( IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip );
904
905 // Mark vector reduction candidates before loop unrolling
906 void mark_reductions( IdealLoopTree *loop );
907
908 // Return true if exp is a constant times an induction var
909 bool is_scaled_iv(Node* exp, Node* iv, int* p_scale);
910
911 // Return true if exp is a scaled induction var plus (or minus) constant
912 bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0);
913
914 // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted
915 ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
916 Deoptimization::DeoptReason reason);
917 void register_control(Node* n, IdealLoopTree *loop, Node* pred);
918
919 // Clone loop predicates to cloned loops (peeled, unswitched)
920 static ProjNode* clone_predicate(ProjNode* predicate_proj, Node* new_entry,
921 Deoptimization::DeoptReason reason,
922 PhaseIdealLoop* loop_phase,
923 PhaseIterGVN* igvn);
924
925 static Node* clone_loop_predicates(Node* old_entry, Node* new_entry,
926 bool clone_limit_check,
927 PhaseIdealLoop* loop_phase,
928 PhaseIterGVN* igvn);
929 Node* clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check);
930
931 static Node* skip_loop_predicates(Node* entry);
932
933 // Find a good location to insert a predicate
934 static ProjNode* find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason);
935 // Find a predicate
936 static Node* find_predicate(Node* entry);
946 // Helper function to collect predicate for eliminating the useless ones
947 void collect_potentially_useful_predicates(IdealLoopTree *loop, Unique_Node_List &predicate_opaque1);
948 void eliminate_useless_predicates();
949
950 // Change the control input of expensive nodes to allow commoning by
951 // IGVN when it is guaranteed to not result in a more frequent
952 // execution of the expensive node. Return true if progress.
953 bool process_expensive_nodes();
954
955 // Check whether node has become unreachable
956 bool is_node_unreachable(Node *n) const {
957 return !has_node(n) || n->is_unreachable(_igvn);
958 }
959
960 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
961 void do_range_check( IdealLoopTree *loop, Node_List &old_new );
962
963 // Create a slow version of the loop by cloning the loop
964 // and inserting an if to select fast-slow versions.
965 ProjNode* create_slow_version_of_loop(IdealLoopTree *loop,
966 Node_List &old_new);
967
968 // Clone loop with an invariant test (that does not exit) and
969 // insert a clone of the test that selects which version to
970 // execute.
971 void do_unswitching (IdealLoopTree *loop, Node_List &old_new);
972
973 // Find candidate "if" for unswitching
974 IfNode* find_unswitching_candidate(const IdealLoopTree *loop) const;
975
976 // Range Check Elimination uses this function!
977 // Constrain the main loop iterations so the affine function:
978 // low_limit <= scale_con * I + offset < upper_limit
979 // always holds true. That is, either increase the number of iterations in
980 // the pre-loop or the post-loop until the condition holds true in the main
981 // loop. Scale_con, offset and limit are all loop invariant.
982 void add_constraint( int stride_con, int scale_con, Node *offset, Node *low_limit, Node *upper_limit, Node *pre_ctrl, Node **pre_limit, Node **main_limit );
983 // Helper function for add_constraint().
984 Node* adjust_limit( int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl );
985
986 // Partially peel loop up through last_peel node.
|
896 // Take steps to maximally unroll the loop. Peel any odd iterations, then
897 // unroll to do double iterations. The next round of major loop transforms
898 // will repeat till the doubled loop body does all remaining iterations in 1
899 // pass.
900 void do_maximally_unroll( IdealLoopTree *loop, Node_List &old_new );
901
902 // Unroll the loop body one step - make each trip do 2 iterations.
903 void do_unroll( IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip );
904
905 // Mark vector reduction candidates before loop unrolling
906 void mark_reductions( IdealLoopTree *loop );
907
908 // Return true if exp is a constant times an induction var
909 bool is_scaled_iv(Node* exp, Node* iv, int* p_scale);
910
911 // Return true if exp is a scaled induction var plus (or minus) constant
912 bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0);
913
914 // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted
915 ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
916 Deoptimization::DeoptReason reason,
917 int opcode);
918 void register_control(Node* n, IdealLoopTree *loop, Node* pred);
919
920 // Clone loop predicates to cloned loops (peeled, unswitched)
921 static ProjNode* clone_predicate(ProjNode* predicate_proj, Node* new_entry,
922 Deoptimization::DeoptReason reason,
923 PhaseIdealLoop* loop_phase,
924 PhaseIterGVN* igvn);
925
926 static Node* clone_loop_predicates(Node* old_entry, Node* new_entry,
927 bool clone_limit_check,
928 PhaseIdealLoop* loop_phase,
929 PhaseIterGVN* igvn);
930 Node* clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check);
931
932 static Node* skip_loop_predicates(Node* entry);
933
934 // Find a good location to insert a predicate
935 static ProjNode* find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason);
936 // Find a predicate
937 static Node* find_predicate(Node* entry);
947 // Helper function to collect predicate for eliminating the useless ones
948 void collect_potentially_useful_predicates(IdealLoopTree *loop, Unique_Node_List &predicate_opaque1);
949 void eliminate_useless_predicates();
950
951 // Change the control input of expensive nodes to allow commoning by
952 // IGVN when it is guaranteed to not result in a more frequent
953 // execution of the expensive node. Return true if progress.
954 bool process_expensive_nodes();
955
956 // Check whether node has become unreachable
957 bool is_node_unreachable(Node *n) const {
958 return !has_node(n) || n->is_unreachable(_igvn);
959 }
960
961 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
962 void do_range_check( IdealLoopTree *loop, Node_List &old_new );
963
964 // Create a slow version of the loop by cloning the loop
965 // and inserting an if to select fast-slow versions.
966 ProjNode* create_slow_version_of_loop(IdealLoopTree *loop,
967 Node_List &old_new,
968 int opcode);
969
970 // Clone loop with an invariant test (that does not exit) and
971 // insert a clone of the test that selects which version to
972 // execute.
973 void do_unswitching (IdealLoopTree *loop, Node_List &old_new);
974
975 // Find candidate "if" for unswitching
976 IfNode* find_unswitching_candidate(const IdealLoopTree *loop) const;
977
978 // Range Check Elimination uses this function!
979 // Constrain the main loop iterations so the affine function:
980 // low_limit <= scale_con * I + offset < upper_limit
981 // always holds true. That is, either increase the number of iterations in
982 // the pre-loop or the post-loop until the condition holds true in the main
983 // loop. Scale_con, offset and limit are all loop invariant.
984 void add_constraint( int stride_con, int scale_con, Node *offset, Node *low_limit, Node *upper_limit, Node *pre_ctrl, Node **pre_limit, Node **main_limit );
985 // Helper function for add_constraint().
986 Node* adjust_limit( int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl );
987
988 // Partially peel loop up through last_peel node.
|