backport: [multiple changes]
2018-06-01 Bill Schmidt <wschmidt@linux.ibm.com> PR tree-optimization/85712 Backport from mainline: 2018-05-23 Bill Schmidt <wschmidt@linux.ibm.com> PR tree-optimization/85712 * gimple-ssa-strength-reduction.c (struct slsr_cand_d): Add first_interp field. (alloc_cand_and_find_basis): Initialize first_interp field. (slsr_process_mul): Modify first_interp field. (slsr_process_add): Likewise. (slsr_process_cast): Modify first_interp field for each new interpretation. (slsr_process_copy): Likewise. (dump_candidate): Dump first_interp field. (replace_mult_candidate): Process all interpretations, not just subsequent ones. (replace_rhs_if_not_dup): Likewise. (replace_one_candidate): Likewise. Backport from mainline: 2018-05-25 Bill Schmidt <wschmidt@linux.ibm.com> PR tree-optimization/85712 * gimple-ssa-strength-reduction.c (replace_one_candidate): Skip if this candidate has already been replaced in-situ by a copy. From-SVN: r261066
This commit is contained in:
parent
70dd0dcefd
commit
ada08cc201
|
@ -1,3 +1,31 @@
|
|||
2018-06-01 Bill Schmidt <wschmidt@linux.ibm.com>
|
||||
|
||||
PR tree-optimization/85712
|
||||
Backport from mainline:
|
||||
2018-05-23 Bill Schmidt <wschmidt@linux.ibm.com>
|
||||
|
||||
PR tree-optimization/85712
|
||||
* gimple-ssa-strength-reduction.c (struct slsr_cand_d): Add
|
||||
first_interp field.
|
||||
(alloc_cand_and_find_basis): Initialize first_interp field.
|
||||
(slsr_process_mul): Modify first_interp field.
|
||||
(slsr_process_add): Likewise.
|
||||
(slsr_process_cast): Modify first_interp field for each new
|
||||
interpretation.
|
||||
(slsr_process_copy): Likewise.
|
||||
(dump_candidate): Dump first_interp field.
|
||||
(replace_mult_candidate): Process all interpretations, not just
|
||||
subsequent ones.
|
||||
(replace_rhs_if_not_dup): Likewise.
|
||||
(replace_one_candidate): Likewise.
|
||||
|
||||
Backport from mainline:
|
||||
2018-05-25 Bill Schmidt <wschmidt@linux.ibm.com>
|
||||
|
||||
PR tree-optimization/85712
|
||||
* gimple-ssa-strength-reduction.c (replace_one_candidate): Skip if
|
||||
this candidate has already been replaced in-situ by a copy.
|
||||
|
||||
2018-05-24 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* config/i386/sse.md (cvtusi2<ssescalarmodesuffix>64<round_name>):
|
||||
|
|
|
@ -266,6 +266,10 @@ struct slsr_cand_d
|
|||
of a statement. */
|
||||
cand_idx next_interp;
|
||||
|
||||
/* Index of the first candidate record in a chain for the same
|
||||
statement. */
|
||||
cand_idx first_interp;
|
||||
|
||||
/* Index of the basis statement S0, if any, in the candidate vector. */
|
||||
cand_idx basis;
|
||||
|
||||
|
@ -643,6 +647,7 @@ alloc_cand_and_find_basis (enum cand_kind kind, gimple *gs, tree base,
|
|||
c->kind = kind;
|
||||
c->cand_num = cand_vec.length () + 1;
|
||||
c->next_interp = 0;
|
||||
c->first_interp = c->cand_num;
|
||||
c->dependent = 0;
|
||||
c->sibling = 0;
|
||||
c->def_phi = kind == CAND_MULT ? find_phi_def (base) : 0;
|
||||
|
@ -1213,6 +1218,7 @@ slsr_process_mul (gimple *gs, tree rhs1, tree rhs2, bool speed)
|
|||
is the stride and RHS2 is the base expression. */
|
||||
c2 = create_mul_ssa_cand (gs, rhs2, rhs1, speed);
|
||||
c->next_interp = c2->cand_num;
|
||||
c2->first_interp = c->cand_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1450,7 +1456,10 @@ slsr_process_add (gimple *gs, tree rhs1, tree rhs2, bool speed)
|
|||
{
|
||||
c2 = create_add_ssa_cand (gs, rhs2, rhs1, false, speed);
|
||||
if (c)
|
||||
c->next_interp = c2->cand_num;
|
||||
{
|
||||
c->next_interp = c2->cand_num;
|
||||
c2->first_interp = c->cand_num;
|
||||
}
|
||||
else
|
||||
add_cand_for_stmt (gs, c2);
|
||||
}
|
||||
|
@ -1573,6 +1582,8 @@ slsr_process_cast (gimple *gs, tree rhs1, bool speed)
|
|||
|
||||
if (base_cand && base_cand->kind != CAND_PHI)
|
||||
{
|
||||
slsr_cand_t first_cand = NULL;
|
||||
|
||||
while (base_cand)
|
||||
{
|
||||
/* Propagate all data from the base candidate except the type,
|
||||
|
@ -1587,6 +1598,12 @@ slsr_process_cast (gimple *gs, tree rhs1, bool speed)
|
|||
base_cand->index, base_cand->stride,
|
||||
ctype, base_cand->stride_type,
|
||||
savings);
|
||||
if (!first_cand)
|
||||
first_cand = c;
|
||||
|
||||
if (first_cand != c)
|
||||
c->first_interp = first_cand->cand_num;
|
||||
|
||||
if (base_cand->next_interp)
|
||||
base_cand = lookup_cand (base_cand->next_interp);
|
||||
else
|
||||
|
@ -1609,6 +1626,7 @@ slsr_process_cast (gimple *gs, tree rhs1, bool speed)
|
|||
c2 = alloc_cand_and_find_basis (CAND_MULT, gs, rhs1, 0,
|
||||
integer_one_node, ctype, sizetype, 0);
|
||||
c->next_interp = c2->cand_num;
|
||||
c2->first_interp = c->cand_num;
|
||||
}
|
||||
|
||||
/* Add the first (or only) interpretation to the statement-candidate
|
||||
|
@ -1633,6 +1651,8 @@ slsr_process_copy (gimple *gs, tree rhs1, bool speed)
|
|||
|
||||
if (base_cand && base_cand->kind != CAND_PHI)
|
||||
{
|
||||
slsr_cand_t first_cand = NULL;
|
||||
|
||||
while (base_cand)
|
||||
{
|
||||
/* Propagate all data from the base candidate. */
|
||||
|
@ -1645,6 +1665,12 @@ slsr_process_copy (gimple *gs, tree rhs1, bool speed)
|
|||
base_cand->index, base_cand->stride,
|
||||
base_cand->cand_type,
|
||||
base_cand->stride_type, savings);
|
||||
if (!first_cand)
|
||||
first_cand = c;
|
||||
|
||||
if (first_cand != c)
|
||||
c->first_interp = first_cand->cand_num;
|
||||
|
||||
if (base_cand->next_interp)
|
||||
base_cand = lookup_cand (base_cand->next_interp);
|
||||
else
|
||||
|
@ -1669,6 +1695,7 @@ slsr_process_copy (gimple *gs, tree rhs1, bool speed)
|
|||
integer_one_node, TREE_TYPE (rhs1),
|
||||
sizetype, 0);
|
||||
c->next_interp = c2->cand_num;
|
||||
c2->first_interp = c->cand_num;
|
||||
}
|
||||
|
||||
/* Add the first (or only) interpretation to the statement-candidate
|
||||
|
@ -1839,8 +1866,9 @@ dump_candidate (slsr_cand_t c)
|
|||
print_generic_expr (dump_file, c->cand_type, 0);
|
||||
fprintf (dump_file, "\n basis: %d dependent: %d sibling: %d\n",
|
||||
c->basis, c->dependent, c->sibling);
|
||||
fprintf (dump_file, " next-interp: %d dead-savings: %d\n",
|
||||
c->next_interp, c->dead_savings);
|
||||
fprintf (dump_file,
|
||||
" next-interp: %d first-interp: %d dead-savings: %d\n",
|
||||
c->next_interp, c->first_interp, c->dead_savings);
|
||||
if (c->def_phi)
|
||||
fprintf (dump_file, " phi: %d\n", c->def_phi);
|
||||
fputs ("\n", dump_file);
|
||||
|
@ -2098,14 +2126,13 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, widest_int bump)
|
|||
tree lhs = gimple_assign_lhs (c->cand_stmt);
|
||||
gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
|
||||
gsi_replace (&gsi, copy_stmt, false);
|
||||
c->cand_stmt = copy_stmt;
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = copy_stmt;
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
stmt_to_print = copy_stmt;
|
||||
|
@ -2132,15 +2159,14 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, widest_int bump)
|
|||
else
|
||||
{
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_assign_set_rhs_with_ops (&gsi, code,
|
||||
basis_name, bump_tree);
|
||||
update_stmt (gsi_stmt (gsi));
|
||||
c->cand_stmt = gsi_stmt (gsi);
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = gsi_stmt (gsi);
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
stmt_to_print = gsi_stmt (gsi);
|
||||
|
@ -3426,14 +3452,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))))
|
||||
{
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_assign_set_rhs_with_ops (&gsi, new_code, new_rhs1, new_rhs2);
|
||||
update_stmt (gsi_stmt (gsi));
|
||||
c->cand_stmt = gsi_stmt (gsi);
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = gsi_stmt (gsi);
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
|
@ -3466,6 +3491,11 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
|
|||
orig_rhs2 = gimple_assign_rhs2 (c->cand_stmt);
|
||||
cand_incr = cand_increment (c);
|
||||
|
||||
/* If orig_rhs2 is NULL, we have already replaced this in situ with
|
||||
a copy statement under another interpretation. */
|
||||
if (!orig_rhs2)
|
||||
return;
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
{
|
||||
fputs ("Replacing: ", dump_file);
|
||||
|
@ -3538,14 +3568,13 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
|
|||
|| !operand_equal_p (rhs2, orig_rhs2, 0))
|
||||
{
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_assign_set_rhs_with_ops (&gsi, MINUS_EXPR, basis_name, rhs2);
|
||||
update_stmt (gsi_stmt (gsi));
|
||||
c->cand_stmt = gsi_stmt (gsi);
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = gsi_stmt (gsi);
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
|
@ -3565,14 +3594,13 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
|
|||
{
|
||||
gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
|
||||
gsi_replace (&gsi, copy_stmt, false);
|
||||
c->cand_stmt = copy_stmt;
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = copy_stmt;
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
|
@ -3582,14 +3610,13 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
|
|||
{
|
||||
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
|
||||
gassign *cast_stmt = gimple_build_assign (lhs, NOP_EXPR, basis_name);
|
||||
slsr_cand_t cc = c;
|
||||
slsr_cand_t cc = lookup_cand (c->first_interp);
|
||||
gimple_set_location (cast_stmt, gimple_location (c->cand_stmt));
|
||||
gsi_replace (&gsi, cast_stmt, false);
|
||||
c->cand_stmt = cast_stmt;
|
||||
while (cc->next_interp)
|
||||
while (cc)
|
||||
{
|
||||
cc = lookup_cand (cc->next_interp);
|
||||
cc->cand_stmt = cast_stmt;
|
||||
cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
|
||||
}
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
|
|
Loading…
Reference in New Issue