Commit b7675b59 by Richard Biener Committed by Richard Biener

re PR tree-optimization/81573 (wrong code at -O3 on x86_64-linux-gnu)

2017-07-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81573
	PR tree-optimization/81494
	* tree-vect-loop.c (vect_create_epilog_for_reduction): Handle
	multi defuse cycle case.

	* gcc.dg/torture/pr81573.c: New testcase.

From-SVN: r250627
parent 719488f8
2017-07-27 Richard Biener <rguenther@suse.de> 2017-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/81573
PR tree-optimization/81494
* tree-vect-loop.c (vect_create_epilog_for_reduction): Handle
multi defuse cycle case.
2017-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/81571 PR tree-optimization/81571
* tree-vect-slp.c (vect_build_slp_tree): Properly verify reduction * tree-vect-slp.c (vect_build_slp_tree): Properly verify reduction
PHIs. PHIs.
......
2017-07-27 Richard Biener <rguenther@suse.de> 2017-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/81573
PR tree-optimization/81494
* gcc.dg/torture/pr81573.c: New testcase.
2017-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/81571 PR tree-optimization/81571
* gcc.dg/torture/pr81571.c: New testcase. * gcc.dg/torture/pr81571.c: New testcase.
......
/* { dg-do run } */
int a = 1, *c = &a, d;
char b;
int main ()
{
for (; b > -27; b--)
{
*c ^= b;
*c ^= 1;
}
while (a > 1)
;
return 0;
}
...@@ -4787,20 +4787,17 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt, ...@@ -4787,20 +4787,17 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
if (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt))) if (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
{ {
tree first_vect = PHI_RESULT (new_phis[0]); tree first_vect = PHI_RESULT (new_phis[0]);
tree tmp;
gassign *new_vec_stmt = NULL; gassign *new_vec_stmt = NULL;
vec_dest = vect_create_destination_var (scalar_dest, vectype); vec_dest = vect_create_destination_var (scalar_dest, vectype);
for (k = 1; k < new_phis.length (); k++) for (k = 1; k < new_phis.length (); k++)
{ {
gimple *next_phi = new_phis[k]; gimple *next_phi = new_phis[k];
tree second_vect = PHI_RESULT (next_phi); tree second_vect = PHI_RESULT (next_phi);
tree tem = make_ssa_name (vec_dest, new_vec_stmt);
tmp = build2 (code, vectype, first_vect, second_vect); new_vec_stmt = gimple_build_assign (tem, code,
new_vec_stmt = gimple_build_assign (vec_dest, tmp); first_vect, second_vect);
first_vect = make_ssa_name (vec_dest, new_vec_stmt);
gimple_assign_set_lhs (new_vec_stmt, first_vect);
gsi_insert_before (&exit_gsi, new_vec_stmt, GSI_SAME_STMT); gsi_insert_before (&exit_gsi, new_vec_stmt, GSI_SAME_STMT);
first_vect = tem;
} }
new_phi_result = first_vect; new_phi_result = first_vect;
...@@ -4810,6 +4807,28 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt, ...@@ -4810,6 +4807,28 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
new_phis.safe_push (new_vec_stmt); new_phis.safe_push (new_vec_stmt);
} }
} }
/* Likewise if we couldn't use a single defuse cycle. */
else if (ncopies > 1)
{
gcc_assert (new_phis.length () == 1);
tree first_vect = PHI_RESULT (new_phis[0]);
gassign *new_vec_stmt = NULL;
vec_dest = vect_create_destination_var (scalar_dest, vectype);
gimple *next_phi = new_phis[0];
for (int k = 1; k < ncopies; ++k)
{
next_phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (next_phi));
tree second_vect = PHI_RESULT (next_phi);
tree tem = make_ssa_name (vec_dest, new_vec_stmt);
new_vec_stmt = gimple_build_assign (tem, code,
first_vect, second_vect);
gsi_insert_before (&exit_gsi, new_vec_stmt, GSI_SAME_STMT);
first_vect = tem;
}
new_phi_result = first_vect;
new_phis.truncate (0);
new_phis.safe_push (new_vec_stmt);
}
else else
new_phi_result = PHI_RESULT (new_phis[0]); new_phi_result = PHI_RESULT (new_phis[0]);
......
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