[PATCH v2 01/13] vect: Change IV increment position to the end of the loop
Alfie Richards <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
This is required for HSSR where the IV increment is not available until the end
of the loop body.
gcc/ChangeLog:
* tree-vect-loop-manip.cc (vect_set_loop_controls_directly):
Change IV increment position when peeled.
* tree-vect-loop.cc
(vect_update_ivs_after_vectorizer_for_early_breaks):
Change IV increment position.
---
gcc/tree-vect-loop-manip.cc | 20 ++++++++++++++++----
gcc/tree-vect-loop.cc | 3 +--
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 96c10340efd..cee3779e37f 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -574,7 +574,10 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
gimple_stmt_iterator incr_gsi;
bool insert_after;
edge exit_e = LOOP_VINFO_MAIN_EXIT (loop_vinfo);
- vect_iv_increment_position (exit_e, &incr_gsi, &insert_after);
+ if (!LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
+ vect_iv_increment_position (exit_e, &incr_gsi, &insert_after);
+ else
+ standard_iv_increment_position (loop, &incr_gsi, &insert_after);
if (LOOP_VINFO_USING_DECREMENTING_IV_P (loop_vinfo))
{
/* Create an IV that counts down from niters_total and whose step
@@ -723,7 +726,10 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
a demotion). */
gimple_seq test_seq = NULL;
test_index = gimple_convert (&test_seq, compare_type, test_index);
- gsi_insert_seq_before (test_gsi, test_seq, GSI_SAME_STMT);
+ if (!LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
+ gsi_insert_seq_before (test_gsi, test_seq, GSI_SAME_STMT);
+ else
+ gsi_insert_seq_after (&incr_gsi, test_seq, GSI_NEW_STMT);
/* Provide a definition of each control in the group. */
tree next_ctrl = NULL_TREE;
@@ -832,14 +838,20 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
gimple_seq stmts = NULL;
next_ctrl = vect_gen_while (&stmts, ctrl_type, test_index,
this_test_limit, "next_mask");
- gsi_insert_seq_before (test_gsi, stmts, GSI_SAME_STMT);
+ if (!LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
+ gsi_insert_seq_before (test_gsi, stmts, GSI_SAME_STMT);
+ else
+ gsi_insert_seq_after (&incr_gsi, stmts, GSI_SAME_STMT);
}
else
{
next_ctrl = make_temp_ssa_name (compare_type, NULL, "next_len");
gimple_seq seq = vect_gen_len (next_ctrl, test_index, this_test_limit,
length_limit);
- gsi_insert_seq_before (test_gsi, seq, GSI_SAME_STMT);
+ if (!LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo))
+ gsi_insert_seq_before (test_gsi, seq, GSI_SAME_STMT);
+ else
+ gsi_insert_seq_after (&incr_gsi, seq, GSI_SAME_STMT);
}
vect_set_loop_control (loop, ctrl, init_ctrl, next_ctrl);
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 0a09ce8bd85..42843d17be8 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11202,8 +11202,7 @@ vect_update_ivs_after_vectorizer_for_early_breaks (loop_vec_info loop_vinfo)
/* Write the adjustments at the end of the iv increment. */
bool insert_after;
gimple_stmt_iterator incr_gsi;
- vect_iv_increment_position (LOOP_VINFO_MAIN_EXIT (loop_vinfo), &incr_gsi,
- &insert_after);
+ standard_iv_increment_position (loop, &incr_gsi, &insert_after);
if (insert_after)
gsi_insert_seq_after (&incr_gsi, stmts, GSI_NEW_STMT);
--
2.43.0