* ...
---
gcc/gimple-ssa-strength-reduction.cc | 29 +++++++++++-----------------
gcc/tree-call-cdce.cc | 6 +++---
gcc/tree-outof-ssa.cc | 5 ++---
gcc/tree-ssa-ifcombine.cc | 14 +++++---------
gcc/tree-ssa-math-opts.cc | 22 ++++++++++-----------
gcc/tree-ssa-phiopt.cc | 15 ++++++--------
gcc/tree-ssa-reassoc.cc | 4 ++--
gcc/tree-ssa-strlen.cc | 9 ++++-----
gcc/tree-vect-generic.cc | 9 ++++++---
gcc/tree-vect-loop-manip.cc | 16 +++++++--------
gcc/ubsan.cc | 4 ++--
gcc/vr-values.cc | 4 ++--
12 files changed, 61 insertions(+), 76 deletions(-)
diff --git a/gcc/gimple-ssa-strength-reduction.cc
b/gcc/gimple-ssa-strength-reduction.cc
index cac7a449d5a..60a64aacf20 100644
--- a/gcc/gimple-ssa-strength-reduction.cc
+++ b/gcc/gimple-ssa-strength-reduction.cc
@@ -2218,14 +2218,12 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name,
offset_int bump,
}
else
{
- gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+ auto gsi = ginsert_iterator::before (c->cand_stmt);
slsr_cand_t cc = lookup_cand (c->first_interp);
tree lhs = gimple_assign_lhs (c->cand_stmt);
- basis_name = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ basis_name = gimple_convert (&gsi, UNKNOWN_LOCATION,
TREE_TYPE (lhs), basis_name);
- bump_tree = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ bump_tree = gimple_convert (&gsi, UNKNOWN_LOCATION,
TREE_TYPE (lhs), bump_tree);
gimple_assign_set_rhs_with_ops (&gsi, code, basis_name, bump_tree);
update_stmt (gsi_stmt (gsi));
@@ -3676,10 +3674,9 @@ static tree
introduce_cast_before_cand (slsr_cand_t c, tree to_type, tree from_expr)
{
tree cast_lhs;
- gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+ auto gsi = ginsert_iterator::before (c->cand_stmt);
- cast_lhs = gimple_convert (&gsi, true, GSI_SAME_STMT,
- gimple_location (c->cand_stmt),
+ cast_lhs = gimple_convert (&gsi, gimple_location (c->cand_stmt),
to_type, from_expr);
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -3711,15 +3708,13 @@ replace_rhs_if_not_dup (enum tree_code new_code, tree
new_rhs1, tree new_rhs2,
|| !operand_equal_p (new_rhs2, old_rhs1, 0))))
{
tree lhs = gimple_assign_lhs (c->cand_stmt);
- gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+ auto gsi = ginsert_iterator::before (c->cand_stmt);
tree rhs2_type = TREE_TYPE (lhs);
if (POINTER_TYPE_P (rhs2_type))
rhs2_type = sizetype;
- new_rhs1 = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ new_rhs1 = gimple_convert (&gsi, UNKNOWN_LOCATION,
TREE_TYPE (lhs), new_rhs1);
- new_rhs2 = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ new_rhs2 = gimple_convert (&gsi, UNKNOWN_LOCATION,
rhs2_type, new_rhs2);
slsr_cand_t cc = lookup_cand (c->first_interp);
gimple_assign_set_rhs_with_ops (&gsi, new_code, new_rhs1, new_rhs2);
@@ -3845,14 +3840,12 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree
basis_name,
|| !operand_equal_p (basis_name, orig_rhs1, 0)
|| !operand_equal_p (rhs2, orig_rhs2, 0))
{
- gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+ auto gsi = ginsert_iterator::before (c->cand_stmt);
tree lhs = gimple_assign_lhs (c->cand_stmt);
slsr_cand_t cc = lookup_cand (c->first_interp);
- basis_name = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ basis_name = gimple_convert (&gsi, UNKNOWN_LOCATION,
TREE_TYPE (lhs), basis_name);
- rhs2 = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ rhs2 = gimple_convert (&gsi, UNKNOWN_LOCATION,
TREE_TYPE (lhs), rhs2);
gimple_assign_set_rhs_with_ops (&gsi, MINUS_EXPR, basis_name, rhs2);
update_stmt (gsi_stmt (gsi));
diff --git a/gcc/tree-call-cdce.cc b/gcc/tree-call-cdce.cc
index 289504fc927..a1e272d7954 100644
--- a/gcc/tree-call-cdce.cc
+++ b/gcc/tree-call-cdce.cc
@@ -1343,13 +1343,13 @@ shrink_wrap_len_call (gcall *call, unsigned len_arg,
tree zero_len_result,
{
gcc_assert (zero_len_result);
location_t loc = gimple_location (call);
- gimple_stmt_iterator gsi = gsi_for_stmt (call);
+ auto gsi = ginsert_iterator::before (call);
- zero_len_result = gimple_convert (&gsi, true, GSI_SAME_STMT, loc,
+ zero_len_result = gimple_convert (&gsi, loc,
TREE_TYPE (lhs), zero_len_result);
gassign *stmt = gimple_build_assign (lhs, zero_len_result);
gimple_set_location (stmt, loc);
- gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ gsi.insert (stmt);
gimple_call_set_lhs (call, NULL_TREE);
SSA_NAME_DEF_STMT (lhs) = stmt;
diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc
index 918dbbedde3..98f85945af8 100644
--- a/gcc/tree-outof-ssa.cc
+++ b/gcc/tree-outof-ssa.cc
@@ -1389,10 +1389,9 @@ insert_backedge_copies (void)
adj = gimple_cond_rhs_ptr (cond);
else
adj = gimple_cond_lhs_ptr (cond);
- gimple_stmt_iterator gsi = gsi_for_stmt (cond);
+ auto gsi = ginsert_iterator::before (cond);
tree newval
- = gimple_build (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ = gimple_build (&gsi, UNKNOWN_LOCATION,
gimple_assign_rhs_code (def),
TREE_TYPE (*adj),
*adj, gimple_assign_rhs2 (def));
diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 0c3e78ef331..438cc3022e0 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -874,19 +874,15 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool
inner_inv,
return false;
/* Do it. */
- gsi = gsi_for_stmt (inner_cond);
+ auto gsi = ginsert_iterator::before (inner_cond);
location_t loc1 = gimple_location (inner_cond);
location_t loc2 = gimple_location (outer_cond);
- t = gimple_build (&gsi, true, GSI_SAME_STMT, loc1, LSHIFT_EXPR,
- TREE_TYPE (name1),
+ t = gimple_build (&gsi, loc1, LSHIFT_EXPR, TREE_TYPE (name1),
build_int_cst (TREE_TYPE (name1), 1), bit1);
- t2 = gimple_build (&gsi, true, GSI_SAME_STMT, loc2, LSHIFT_EXPR,
- TREE_TYPE (name1),
+ t2 = gimple_build (&gsi, loc2, LSHIFT_EXPR, TREE_TYPE (name1),
build_int_cst (TREE_TYPE (name1), 1), bit2);
- t = gimple_build (&gsi, true, GSI_SAME_STMT, loc1, BIT_IOR_EXPR,
- TREE_TYPE (name1), t, t2);
- t2 = gimple_build (&gsi, true, GSI_SAME_STMT, loc1, BIT_AND_EXPR,
- TREE_TYPE (name1), name1, t);
+ t = gimple_build (&gsi, loc1, BIT_IOR_EXPR, TREE_TYPE (name1), t, t2);
+ t2 = gimple_build (&gsi, loc1, BIT_AND_EXPR, TREE_TYPE (name1), name1,
t);
t = fold_build2 (EQ_EXPR, boolean_type_node, t2, t);
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index c4a1d7bcf0b..615c9f0246e 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1641,7 +1641,8 @@ static tree
build_and_insert_cast (gimple_stmt_iterator *gsi, location_t loc,
tree type, tree val)
{
- return gimple_convert (gsi, true, GSI_SAME_STMT, loc, type, val);
+ auto gii = ginsert_iterator::before (*gsi);
+ return gimple_convert (&gii, loc, type, val);
}
struct pow_synth_sqrt_info
@@ -3182,15 +3183,13 @@ convert_mult_to_fma_1 (tree mul_result, tree op1, tree
op2)
if (negate_p)
mulop1 = gimple_build (&seq, NEGATE_EXPR, TREE_TYPE (mulop1), mulop1);
- if (seq)
- gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
-
/* Ensure all the operands are of the same type. Use the type of the
addend as that's the statement being replaced. */
- op2 = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION, TREE_TYPE (addop), op2);
- mulop1 = gimple_convert (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION, TREE_TYPE (addop), mulop1);
+ op2 = gimple_convert (&seq, TREE_TYPE (addop), op2);
+ mulop1 = gimple_convert (&seq, TREE_TYPE (addop), mulop1);
+
+ if (seq)
+ gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
if (len)
fma_stmt
@@ -4407,10 +4406,9 @@ match_spaceship (gimple_stmt_iterator *gsi, gphi *phi)
We must use GIMPLE assignments rather than fold_convert because
gimple_call arguments must be valid GIMPLE values (SSA names or
constants), not tree expressions. */
- ops[0] = gimple_convert (gsi, true, GSI_SAME_STMT, UNKNOWN_LOCATION,
- promoted_type, ops[0]);
- ops[1] = gimple_convert (gsi, true, GSI_SAME_STMT, UNKNOWN_LOCATION,
- promoted_type, ops[1]);
+ auto gii = ginsert_iterator::before (*gsi);
+ ops[0] = gimple_convert (&gii, UNKNOWN_LOCATION, promoted_type, ops[0]);
+ ops[1] = gimple_convert (&gii, UNKNOWN_LOCATION, promoted_type, ops[1]);
tree spaceship_arg_3 = is_unsigned ? build_one_cst (integer_type_node)
: build_minus_one_cst (integer_type_node);
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index e12dc7a8b0c..825b1c89d87 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -3778,8 +3778,8 @@ factor_out_conditional_load (edge e0, edge e1,
basic_block merge, gphi *phi,
gphi *pphi = create_phi_node (index, merge);
add_phi_arg (pphi, index0, e0, gimple_phi_arg_location (phi,
e0->dest_idx));
add_phi_arg (pphi, index1, e1, gimple_phi_arg_location (phi,
e1->dest_idx));
- p0 = gimple_build (&gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ auto gii = ginsert_iterator::before (gsi);
+ p0 = gimple_build (&gii, UNKNOWN_LOCATION,
POINTER_PLUS_EXPR, atype, p0, index);
/* Since we already have the same pointer for both, just set that way.
Also the index offset is already 0 because we just did the add. */
@@ -3795,21 +3795,18 @@ factor_out_conditional_load (edge e0, edge e1,
basic_block merge, gphi *phi,
}
else
{
- gimple_stmt_iterator gsi_index;
/* When the indices are different create 2 new pointers on each
of the middle bb right after the original load.
Note in the case of 0 index, gimple_build just returns
the original pointer. */
- gsi_index = gsi_for_stmt (load0);
+ auto gsi_index = ginsert_iterator::after (load0);
index0 = fold_convert (sizetype, index0);
- p0 = gimple_build (&gsi_index, false, GSI_SAME_STMT,
- gimple_location (load0),
+ p0 = gimple_build (&gsi_index, gimple_location (load0),
POINTER_PLUS_EXPR, atype, p0, index0);
- gsi_index = gsi_for_stmt (load1);
+ gsi_index = ginsert_iterator::after (load1);
index1 = fold_convert (sizetype, index1);
- p1 = gimple_build (&gsi_index, false, GSI_SAME_STMT,
- gimple_location (load1),
+ p1 = gimple_build (&gsi_index, gimple_location (load1),
POINTER_PLUS_EXPR, atype, p1, index1);
newindex = build_zero_cst (atype);
if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index dec64883891..c2f8a79d645 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -4279,10 +4279,10 @@ optimize_vec_cond_expr (tree_code opcode,
vec<operand_entry *> *ops)
fputc ('\n', dump_file);
}
- gimple_stmt_iterator gsi = gsi_for_stmt (vcond0);
+ auto gsi = ginsert_iterator::before (vcond0);
tree exp = force_gimple_operand_gsi (&gsi, comb, true, NULL_TREE,
true, GSI_SAME_STMT);
- tree res = gimple_build (&gsi, true, GSI_SAME_STMT, UNKNOWN_LOCATION,
+ tree res = gimple_build (&gsi, UNKNOWN_LOCATION,
VEC_COND_EXPR, TREE_TYPE (elt0), exp,
constant_boolean_node (true,
TREE_TYPE (elt0)),
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index d6949441f31..a72349f61e4 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -851,7 +851,7 @@ get_string_length (strinfo *si)
gimple *stmt = si->stmt, *lenstmt = NULL;
tree callee, lhs, fn, tem;
location_t loc;
- gimple_stmt_iterator gsi;
+ ginsert_iterator gsi = gsi; /* ick, but ick below, too */
gcc_assert (is_gimple_call (stmt));
callee = gimple_call_fndecl (stmt);
@@ -867,7 +867,7 @@ get_string_length (strinfo *si)
{
case BUILT_IN_STRCAT:
case BUILT_IN_STRCAT_CHK:
- gsi = gsi_for_stmt (stmt);
+ gsi = ginsert_iterator::before (stmt);
fn = builtin_decl_implicit (BUILT_IN_STRLEN);
gcc_assert (lhs == NULL_TREE);
tem = unshare_expr (gimple_call_arg (stmt, 0));
@@ -877,10 +877,9 @@ get_string_length (strinfo *si)
gimple_set_vuse (lenstmt, gimple_vuse (stmt));
gsi_insert_before (&gsi, lenstmt, GSI_SAME_STMT);
tem = gimple_call_arg (stmt, 0);
- lhs = gimple_convert_to_ptrofftype (&gsi, true, GSI_SAME_STMT,
+ lhs = gimple_convert_to_ptrofftype (&gsi,
gimple_location (stmt), lhs);
- tem = gimple_build (&gsi, true, GSI_SAME_STMT,
- gimple_location (stmt), POINTER_PLUS_EXPR,
+ tem = gimple_build (&gsi, gimple_location (stmt), POINTER_PLUS_EXPR,
TREE_TYPE (gimple_call_arg (stmt, 0)),
tem, lhs);
gimple_call_set_arg (stmt, 0, tem);
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index a8c31974973..7751ae2122e 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -56,7 +56,8 @@ gimplify_build3 (gimple_stmt_iterator *gsi, enum tree_code
code,
tree type, tree a, tree b, tree c)
{
location_t loc = gimple_location (gsi_stmt (*gsi));
- return gimple_build (gsi, true, GSI_SAME_STMT, loc, code, type, a, b, c);
+ auto gii = ginsert_iterator::before (*gsi);
+ return gimple_build (&gii, loc, code, type, a, b, c);
}
/* Build a binary operation and gimplify it. Emit code before GSI.
@@ -67,7 +68,8 @@ gimplify_build2 (gimple_stmt_iterator *gsi, enum tree_code
code,
tree type, tree a, tree b)
{
location_t loc = gimple_location (gsi_stmt (*gsi));
- return gimple_build (gsi, true, GSI_SAME_STMT, loc, code, type, a, b);
+ auto gii = ginsert_iterator::before (*gsi);
+ return gimple_build (&gii, loc, code, type, a, b);
}
/* Build a unary operation and gimplify it. Emit code before GSI.
@@ -78,7 +80,8 @@ gimplify_build1 (gimple_stmt_iterator *gsi, enum tree_code
code, tree type,
tree a)
{
location_t loc = gimple_location (gsi_stmt (*gsi));
- return gimple_build (gsi, true, GSI_SAME_STMT, loc, code, type, a);
+ auto gii = ginsert_iterator::before (*gsi);
+ return gimple_build (&gii, loc, code, type, a);
}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index ec9dec1b713..5d16311c466 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -523,6 +523,7 @@ vect_set_loop_controls_directly (class loop *loop,
loop_vec_info loop_vinfo,
handles in total, the number that it handles for each iteration
of the vector loop, and the number that it should skip during the
first iteration of the vector loop. */
+ auto loop_cond_gii = ginsert_iterator::before (loop_cond_gsi);
tree nitems_total = niters;
tree nitems_vf
= build_int_cst (iv_type, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
@@ -530,7 +531,7 @@ vect_set_loop_controls_directly (class loop *loop,
loop_vec_info loop_vinfo,
= LOOP_VINFO_IV_INCREMENT_INVARIANT_P (loop_vinfo)
? gimple_convert (preheader_seq, iv_type,
LOOP_VINFO_IV_INCREMENT (loop_vinfo))
- : gimple_convert (&loop_cond_gsi, true, GSI_SAME_STMT, UNKNOWN_LOCATION,
+ : gimple_convert (&loop_cond_gii, UNKNOWN_LOCATION,
iv_type, LOOP_VINFO_IV_INCREMENT (loop_vinfo));
tree nitems_skip = niters_skip;
@@ -547,7 +548,7 @@ vect_set_loop_controls_directly (class loop *loop,
loop_vec_info loop_vinfo,
nitems_step = LOOP_VINFO_IV_INCREMENT_INVARIANT_P (loop_vinfo)
? gimple_build (preheader_seq, MULT_EXPR, iv_type,
nitems_step, iv_factor)
- : gimple_build (&loop_cond_gsi, true, GSI_SAME_STMT,
+ : gimple_build (&loop_cond_gii,
UNKNOWN_LOCATION, MULT_EXPR, iv_type,
nitems_step, iv_factor);
if (nitems_skip)
@@ -1094,19 +1095,19 @@ vect_set_loop_condition_partial_vectors_avx512 (class
loop *loop,
/* index_after_incr is the IV specifying the remaining iterations in
the next iteration. */
tree rem = index_after_incr;
+ auto incr_gii = ginsert_iterator::after (incr_gsi);
/* When the data type for the compare to produce the mask is
smaller than the IV type we need to saturate. Saturate to
the smallest possible value (IV_TYPE) so we only have to
saturate once (CSE will catch redundant ones we add). */
if (TYPE_PRECISION (TREE_TYPE (vectype)) < TYPE_PRECISION (iv_type))
- rem = gimple_build (&incr_gsi, false, GSI_CONTINUE_LINKING,
- UNKNOWN_LOCATION,
+ rem = gimple_build (&incr_gii, UNKNOWN_LOCATION,
MIN_EXPR, TREE_TYPE (rem), rem, iv_step);
- rem = gimple_convert (&incr_gsi, false, GSI_CONTINUE_LINKING,
+ rem = gimple_convert (&incr_gii,
UNKNOWN_LOCATION, TREE_TYPE (vectype), rem);
/* Build a data vector composed of the remaining iterations. */
- rem = gimple_build_vector_from_val (&incr_gsi, false,
GSI_CONTINUE_LINKING,
+ rem = gimple_build_vector_from_val (&incr_gii,
UNKNOWN_LOCATION, vectype, rem);
/* Provide a definition of each vector in the control group. */
@@ -1197,8 +1198,7 @@ vect_set_loop_condition_partial_vectors_avx512 (class
loop *loop,
}
/* Get the control value for the next iteration of the loop. */
- next_ctrl = gimple_build (&incr_gsi, false, GSI_CONTINUE_LINKING,
- UNKNOWN_LOCATION,
+ next_ctrl = gimple_build (&incr_gii, UNKNOWN_LOCATION,
LT_EXPR, ctrl_type, cmp_series, rem);
vect_set_loop_control (loop, ctrl, init_ctrl, next_ctrl);
diff --git a/gcc/ubsan.cc b/gcc/ubsan.cc
index 79a863b46ce..9ad4a4386cd 100644
--- a/gcc/ubsan.cc
+++ b/gcc/ubsan.cc
@@ -1263,8 +1263,8 @@ ubsan_expand_ptr_ifn (gimple_stmt_iterator *gsip)
gimple_set_location (g, loc);
gsi_insert_after (&gsi2, g, GSI_NEW_STMT);
- tree t = gimple_build (&gsi, true, GSI_SAME_STMT,
- loc, NOP_EXPR, ssizetype, off);
+ auto gii = ginsert_iterator::before (gsi);
+ tree t = gimple_build (&gii, loc, NOP_EXPR, ssizetype, off);
g = gimple_build_cond (GE_EXPR, t, ssize_int (0),
NULL_TREE, NULL_TREE);
}
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index f0d9a71bd40..1fb8e878b9c 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -1807,8 +1807,8 @@ simplify_using_ranges::simplify (gimple_stmt_iterator
*gsi)
in divide by zero, new_rhs1 / new_rhs will be NULL_TREE. */
if (new_rhs1 && new_rhs2)
{
- tree cond = gimple_build (gsi, true, GSI_SAME_STMT,
- UNKNOWN_LOCATION,
+ auto gii = ginsert_iterator::before (*gsi);
+ tree cond = gimple_build (&gii, UNKNOWN_LOCATION,
EQ_EXPR, boolean_type_node,
cmp_var, val1);
gimple_assign_set_rhs_with_ops (gsi,
--
2.51.0