VECT: Add tree_code into "creat_iv" and allow it can handle MINUS_EXPR IV
This patch is going to be commited after bootstrap && regression on X86 PASSED. Thanks Richards. gcc/ChangeLog: * cfgloopmanip.cc (create_empty_loop_on_edge): Add PLUS_EXPR. * gimple-loop-interchange.cc (tree_loop_interchange::map_inductions_to_loop): Ditto. * tree-ssa-loop-ivcanon.cc (create_canonical_iv): Ditto. * tree-ssa-loop-ivopts.cc (create_new_iv): Ditto. * tree-ssa-loop-manip.cc (create_iv): Ditto. (tree_transform_and_unroll_loop): Ditto. (canonicalize_loop_ivs): Ditto. * tree-ssa-loop-manip.h (create_iv): Ditto. * tree-vect-data-refs.cc (vect_create_data_ref_ptr): Ditto. * tree-vect-loop-manip.cc (vect_set_loop_controls_directly): Ditto. (vect_set_loop_condition_normal): Ditto. * tree-vect-loop.cc (vect_create_epilog_for_reduction): Ditto. * tree-vect-stmts.cc (vectorizable_store): Ditto. (vectorizable_load): Ditto. Signed-off-by: Juzhe Zhong <juzhe.zhong@rivai.ai>
This commit is contained in:
parent
0440b774ea
commit
0918360d70
10 changed files with 29 additions and 26 deletions
|
@ -826,7 +826,7 @@ create_empty_loop_on_edge (edge entry_edge,
|
|||
}
|
||||
|
||||
gsi = gsi_last_bb (loop_header);
|
||||
create_iv (initial_value, stride, iv, loop, &gsi, false,
|
||||
create_iv (initial_value, PLUS_EXPR, stride, iv, loop, &gsi, false,
|
||||
iv_before, iv_after);
|
||||
|
||||
/* Insert loop exit condition. */
|
||||
|
|
|
@ -1185,7 +1185,7 @@ tree_loop_interchange::map_inductions_to_loop (loop_cand &src, loop_cand &tgt)
|
|||
tree var_before, var_after;
|
||||
tree base = unshare_expr (iv->init_expr);
|
||||
tree step = unshare_expr (iv->step);
|
||||
create_iv (base, step, SSA_NAME_VAR (iv->var),
|
||||
create_iv (base, PLUS_EXPR, step, SSA_NAME_VAR (iv->var),
|
||||
tgt.m_loop, &incr_pos, false, &var_before, &var_after);
|
||||
bitmap_set_bit (m_dce_seeds, SSA_NAME_VERSION (var_before));
|
||||
bitmap_set_bit (m_dce_seeds, SSA_NAME_VERSION (var_after));
|
||||
|
|
|
@ -113,7 +113,7 @@ create_canonical_iv (class loop *loop, edge exit, tree niter,
|
|||
niter,
|
||||
build_int_cst (type, 1));
|
||||
incr_at = gsi_last_bb (in->src);
|
||||
create_iv (niter,
|
||||
create_iv (niter, PLUS_EXPR,
|
||||
build_int_cst (type, -1),
|
||||
NULL_TREE, loop,
|
||||
&incr_at, false, var_before, &var);
|
||||
|
|
|
@ -7267,7 +7267,7 @@ create_new_iv (struct ivopts_data *data, struct iv_cand *cand)
|
|||
|
||||
base = unshare_expr (cand->iv->base);
|
||||
|
||||
create_iv (base, unshare_expr (cand->iv->step),
|
||||
create_iv (base, PLUS_EXPR, unshare_expr (cand->iv->step),
|
||||
cand->var_before, data->current_loop,
|
||||
&incr_pos, after, &cand->var_before, &cand->var_after);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,9 @@ along with GCC; see the file COPYING3. If not see
|
|||
so that we can free them all at once. */
|
||||
static bitmap_obstack loop_renamer_obstack;
|
||||
|
||||
/* Creates an induction variable with value BASE + STEP * iteration in LOOP.
|
||||
/* Creates an induction variable with value BASE (+/-) STEP * iteration in LOOP.
|
||||
If INCR_OP is PLUS_EXPR, the induction variable is BASE + STEP * iteration.
|
||||
If INCR_OP is MINUS_EXPR, the induction variable is BASE - STEP * iteration.
|
||||
It is expected that neither BASE nor STEP are shared with other expressions
|
||||
(unless the sharing rules allow this). Use VAR as a base var_decl for it
|
||||
(if NULL, a new temporary will be created). The increment will occur at
|
||||
|
@ -57,16 +59,16 @@ static bitmap_obstack loop_renamer_obstack;
|
|||
VAR_AFTER (unless they are NULL). */
|
||||
|
||||
void
|
||||
create_iv (tree base, tree step, tree var, class loop *loop,
|
||||
gimple_stmt_iterator *incr_pos, bool after,
|
||||
tree *var_before, tree *var_after)
|
||||
create_iv (tree base, tree_code incr_op, tree step, tree var, class loop *loop,
|
||||
gimple_stmt_iterator *incr_pos, bool after, tree *var_before,
|
||||
tree *var_after)
|
||||
{
|
||||
gassign *stmt;
|
||||
gphi *phi;
|
||||
tree initial, step1;
|
||||
gimple_seq stmts;
|
||||
tree vb, va;
|
||||
enum tree_code incr_op = PLUS_EXPR;
|
||||
gcc_assert (incr_op == PLUS_EXPR || incr_op == MINUS_EXPR);
|
||||
edge pe = loop_preheader_edge (loop);
|
||||
|
||||
if (var != NULL_TREE)
|
||||
|
@ -93,7 +95,7 @@ create_iv (tree base, tree step, tree var, class loop *loop,
|
|||
step1 = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
|
||||
if (tree_int_cst_lt (step1, step))
|
||||
{
|
||||
incr_op = MINUS_EXPR;
|
||||
incr_op = (incr_op == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
|
||||
step = step1;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ create_iv (tree base, tree step, tree var, class loop *loop,
|
|||
if (!tree_expr_nonnegative_warnv_p (step, &ovf)
|
||||
&& may_negate_without_overflow_p (step))
|
||||
{
|
||||
incr_op = MINUS_EXPR;
|
||||
incr_op = (incr_op == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
|
||||
step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
|
||||
}
|
||||
}
|
||||
|
@ -1365,7 +1367,7 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
|
|||
tree ctr_before, ctr_after;
|
||||
gimple_stmt_iterator bsi = gsi_last_nondebug_bb (new_exit->src);
|
||||
exit_if = as_a <gcond *> (gsi_stmt (bsi));
|
||||
create_iv (exit_base, exit_step, NULL_TREE, loop,
|
||||
create_iv (exit_base, PLUS_EXPR, exit_step, NULL_TREE, loop,
|
||||
&bsi, false, &ctr_before, &ctr_after);
|
||||
gimple_cond_set_code (exit_if, exit_cmp);
|
||||
gimple_cond_set_lhs (exit_if, ctr_after);
|
||||
|
@ -1580,8 +1582,8 @@ canonicalize_loop_ivs (class loop *loop, tree *nit, bool bump_in_latch)
|
|||
gsi = gsi_last_bb (loop->latch);
|
||||
else
|
||||
gsi = gsi_last_nondebug_bb (loop->header);
|
||||
create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
|
||||
loop, &gsi, bump_in_latch, &var_before, NULL);
|
||||
create_iv (build_int_cst_type (type, 0), PLUS_EXPR, build_int_cst (type, 1),
|
||||
NULL_TREE, loop, &gsi, bump_in_latch, &var_before, NULL);
|
||||
|
||||
rewrite_all_phi_nodes_with_iv (loop, var_before);
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ along with GCC; see the file COPYING3. If not see
|
|||
|
||||
typedef void (*transform_callback)(class loop *, void *);
|
||||
|
||||
extern void create_iv (tree, tree, tree, class loop *, gimple_stmt_iterator *,
|
||||
bool, tree *, tree *);
|
||||
extern void create_iv (tree, tree_code, tree, tree, class loop *,
|
||||
gimple_stmt_iterator *, bool, tree *, tree *);
|
||||
extern void rewrite_into_loop_closed_ssa (bitmap, unsigned);
|
||||
extern void verify_loop_closed_ssa (bool, class loop * = NULL);
|
||||
|
||||
|
|
|
@ -5099,7 +5099,7 @@ vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info stmt_info,
|
|||
|
||||
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
|
||||
|
||||
create_iv (aggr_ptr_init,
|
||||
create_iv (aggr_ptr_init, PLUS_EXPR,
|
||||
fold_convert (aggr_ptr_type, iv_step),
|
||||
aggr_ptr, loop, &incr_gsi, insert_after,
|
||||
&indx_before_incr, &indx_after_incr);
|
||||
|
@ -5129,9 +5129,9 @@ vect_create_data_ref_ptr (vec_info *vinfo, stmt_vec_info stmt_info,
|
|||
{
|
||||
standard_iv_increment_position (containing_loop, &incr_gsi,
|
||||
&insert_after);
|
||||
create_iv (aptr, fold_convert (aggr_ptr_type, DR_STEP (dr)), aggr_ptr,
|
||||
containing_loop, &incr_gsi, insert_after, &indx_before_incr,
|
||||
&indx_after_incr);
|
||||
create_iv (aptr, PLUS_EXPR, fold_convert (aggr_ptr_type, DR_STEP (dr)),
|
||||
aggr_ptr, containing_loop, &incr_gsi, insert_after,
|
||||
&indx_before_incr, &indx_after_incr);
|
||||
incr = gsi_stmt (incr_gsi);
|
||||
|
||||
/* Copy the points-to information if it exists. */
|
||||
|
|
|
@ -468,8 +468,9 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
|
|||
gimple_stmt_iterator incr_gsi;
|
||||
bool insert_after;
|
||||
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
|
||||
create_iv (build_int_cst (iv_type, 0), nitems_step, NULL_TREE, loop,
|
||||
&incr_gsi, insert_after, &index_before_incr, &index_after_incr);
|
||||
create_iv (build_int_cst (iv_type, 0), PLUS_EXPR, nitems_step, NULL_TREE,
|
||||
loop, &incr_gsi, insert_after, &index_before_incr,
|
||||
&index_after_incr);
|
||||
|
||||
tree zero_index = build_int_cst (compare_type, 0);
|
||||
tree test_index, test_limit, first_limit;
|
||||
|
@ -893,7 +894,7 @@ vect_set_loop_condition_normal (class loop *loop, tree niters, tree step,
|
|||
}
|
||||
|
||||
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
|
||||
create_iv (init, step, NULL_TREE, loop,
|
||||
create_iv (init, PLUS_EXPR, step, NULL_TREE, loop,
|
||||
&incr_gsi, insert_after, &indx_before_incr, &indx_after_incr);
|
||||
indx_after_incr = force_gimple_operand_gsi (&loop_cond_gsi, indx_after_incr,
|
||||
true, NULL_TREE, true,
|
||||
|
|
|
@ -5567,7 +5567,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
|
|||
gimple_stmt_iterator incr_gsi;
|
||||
bool insert_after;
|
||||
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
|
||||
create_iv (series_vect, vec_step, NULL_TREE, loop, &incr_gsi,
|
||||
create_iv (series_vect, PLUS_EXPR, vec_step, NULL_TREE, loop, &incr_gsi,
|
||||
insert_after, &indx_before_incr, &indx_after_incr);
|
||||
|
||||
/* Next create a new phi node vector (NEW_PHI_TREE) which starts
|
||||
|
|
|
@ -8286,7 +8286,7 @@ vectorizable_store (vec_info *vinfo,
|
|||
|
||||
stride_base = cse_and_gimplify_to_preheader (loop_vinfo, stride_base);
|
||||
ivstep = cse_and_gimplify_to_preheader (loop_vinfo, ivstep);
|
||||
create_iv (stride_base, ivstep, NULL,
|
||||
create_iv (stride_base, PLUS_EXPR, ivstep, NULL,
|
||||
loop, &incr_gsi, insert_after,
|
||||
&offvar, NULL);
|
||||
incr = gsi_stmt (incr_gsi);
|
||||
|
@ -9457,7 +9457,7 @@ vectorizable_load (vec_info *vinfo,
|
|||
|
||||
stride_base = cse_and_gimplify_to_preheader (loop_vinfo, stride_base);
|
||||
ivstep = cse_and_gimplify_to_preheader (loop_vinfo, ivstep);
|
||||
create_iv (stride_base, ivstep, NULL,
|
||||
create_iv (stride_base, PLUS_EXPR, ivstep, NULL,
|
||||
loop, &incr_gsi, insert_after,
|
||||
&offvar, NULL);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue