Commit d822f3d5 by Bin Cheng Committed by Jeff Law

re PR tree-optimization/79663 (r244815 causes 10% regression for spec1k/172.mgrid on AArch64)

2017-01-21  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/79663
	* tree-predcom.c (combine_chains): Process refs in reverse order
	only for ZERO length chains, and add explaining comment.

From-SVN: r245689
parent 06b909b0
2017-02-23 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/79663
* tree-predcom.c (combine_chains): Process refs in reverse order
only for ZERO length chains, and add explaining comment.
2017-02-23 Jeff Law <law@redhat.com> 2017-02-23 Jeff Law <law@redhat.com>
PR tree-optimization/79578 PR tree-optimization/79578
......
...@@ -2283,7 +2283,7 @@ combine_chains (chain_p ch1, chain_p ch2) ...@@ -2283,7 +2283,7 @@ combine_chains (chain_p ch1, chain_p ch2)
enum tree_code op = ERROR_MARK; enum tree_code op = ERROR_MARK;
bool swap = false; bool swap = false;
chain_p new_chain; chain_p new_chain;
unsigned i; int i, j, num;
gimple *root_stmt; gimple *root_stmt;
tree rslt_type = NULL_TREE; tree rslt_type = NULL_TREE;
...@@ -2305,6 +2305,9 @@ combine_chains (chain_p ch1, chain_p ch2) ...@@ -2305,6 +2305,9 @@ combine_chains (chain_p ch1, chain_p ch2)
return NULL; return NULL;
} }
ch1->combined = true;
ch2->combined = true;
if (swap) if (swap)
std::swap (ch1, ch2); std::swap (ch1, ch2);
...@@ -2317,39 +2320,41 @@ combine_chains (chain_p ch1, chain_p ch2) ...@@ -2317,39 +2320,41 @@ combine_chains (chain_p ch1, chain_p ch2)
new_chain->length = ch1->length; new_chain->length = ch1->length;
gimple *insert = NULL; gimple *insert = NULL;
auto_vec<dref> tmp_refs; num = ch1->refs.length ();
gcc_assert (ch1->refs.length () == ch2->refs.length ()); i = (new_chain->length == 0) ? num - 1 : 0;
/* Process in reverse order so dominance point is ready when it comes j = (new_chain->length == 0) ? -1 : 1;
to the root ref. */ /* For ZERO length chain, process refs in reverse order so that dominant
for (i = ch1->refs.length (); i > 0; i--) position is ready when it comes to the root ref.
{ For non-ZERO length chain, process refs in order. See PR79663. */
r1 = ch1->refs[i - 1]; for (; num > 0; num--, i += j)
r2 = ch2->refs[i - 1]; {
r1 = ch1->refs[i];
r2 = ch2->refs[i];
nw = XCNEW (struct dref_d); nw = XCNEW (struct dref_d);
nw->distance = r1->distance; nw->distance = r1->distance;
nw->stmt = stmt_combining_refs (r1, r2, i == 1 ? insert : NULL);
/* Record dominance point where root combined stmt should be inserted /* For ZERO length chain, insert combined stmt of root ref at dominant
for chains with 0 length. Though all root refs dominate following position. */
refs, it's possible the combined stmt doesn't. See PR70754. */ nw->stmt = stmt_combining_refs (r1, r2, i == 0 ? insert : NULL);
if (ch1->length == 0 /* For ZERO length chain, record dominant position where combined stmt
of root ref should be inserted. In this case, though all root refs
dominate following ones, it's possible that combined stmt doesn't.
See PR70754. */
if (new_chain->length == 0
&& (insert == NULL || stmt_dominates_stmt_p (nw->stmt, insert))) && (insert == NULL || stmt_dominates_stmt_p (nw->stmt, insert)))
insert = nw->stmt; insert = nw->stmt;
tmp_refs.safe_push (nw); new_chain->refs.safe_push (nw);
} }
/* Restore the order for new chain's refs. */
for (i = tmp_refs.length (); i > 0; i--)
new_chain->refs.safe_push (tmp_refs[i - 1]);
ch1->combined = true;
ch2->combined = true;
/* For chains with 0 length, has_max_use_after must be true since root
combined stmt must dominates others. */
if (new_chain->length == 0) if (new_chain->length == 0)
{ {
/* Restore the order for ZERO length chain's refs. */
num = new_chain->refs.length () >> 1;
for (i = 0, j = new_chain->refs.length () - 1; i < num; i++, j--)
std::swap (new_chain->refs[i], new_chain->refs[j]);
/* For ZERO length chain, has_max_use_after must be true since root
combined stmt must dominates others. */
new_chain->has_max_use_after = true; new_chain->has_max_use_after = true;
return new_chain; return new_chain;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment