Commit bf329927 by Richard Biener Committed by Richard Biener

re PR tree-optimization/87665 (gcc HEAD (svn: 265340) breaks elements on resize)

2018-10-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/87665
	* tree-vect-data-refs.c (vect_preserves_scalar_order_p): Adjust
	to reflect reality.

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

From-SVN: r265452
parent 4b763dee
2018-10-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/87665
* tree-vect-data-refs.c (vect_preserves_scalar_order_p): Adjust
to reflect reality.
2018-10-12 Jeff Law <law@redhat.com> 2018-10-12 Jeff Law <law@redhat.com>
* config/h8300/h8300.c (h8300_expand_prologue): Fix stm generation * config/h8300/h8300.c (h8300_expand_prologue): Fix stm generation
2018-10-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/87665
* gcc.dg/torture/pr87665.c: New testcase.
2018-10-23 Jakub Jelinek <jakub@redhat.com> 2018-10-23 Jakub Jelinek <jakub@redhat.com>
* g++.dg/cpp2a/lambda-this3.C: Limit dg-bogus directives to c++17_down * g++.dg/cpp2a/lambda-this3.C: Limit dg-bogus directives to c++17_down
......
/* { dg-do run } */
struct X { long x; long y; };
struct X a[1024], b[1024];
void foo ()
{
for (int i = 0; i < 1024; ++i)
{
long tem = a[i].x;
a[i].x = 0;
b[i].x = tem;
b[i].y = a[i].y;
}
}
int main()
{
for (int i = 0; i < 1024; ++i)
a[i].x = i;
foo ();
for (int i = 0; i < 1024; ++i)
if (b[i].x != i)
__builtin_abort();
return 0;
}
...@@ -210,16 +210,26 @@ vect_preserves_scalar_order_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b) ...@@ -210,16 +210,26 @@ vect_preserves_scalar_order_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b)
return true; return true;
/* STMT_A and STMT_B belong to overlapping groups. All loads in a /* STMT_A and STMT_B belong to overlapping groups. All loads in a
group are emitted at the position of the first scalar load and all group are emitted at the position of the last scalar load and all
stores in a group are emitted at the position of the last scalar store. stores in a group are emitted at the position of the last scalar store.
Thus writes will happen no earlier than their current position Compute that position and check whether the resulting order matches
(but could happen later) while reads will happen no later than their the current one. */
current position (but could happen earlier). Reordering is therefore stmt_vec_info last_a = DR_GROUP_FIRST_ELEMENT (stmtinfo_a);
only possible if the first access is a write. */ if (last_a)
stmtinfo_a = vect_orig_stmt (stmtinfo_a); for (stmt_vec_info s = DR_GROUP_NEXT_ELEMENT (last_a); s;
stmtinfo_b = vect_orig_stmt (stmtinfo_b); s = DR_GROUP_NEXT_ELEMENT (s))
stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b); last_a = get_later_stmt (last_a, s);
return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info)); else
last_a = stmtinfo_a;
stmt_vec_info last_b = DR_GROUP_FIRST_ELEMENT (stmtinfo_b);
if (last_b)
for (stmt_vec_info s = DR_GROUP_NEXT_ELEMENT (last_b); s;
s = DR_GROUP_NEXT_ELEMENT (s))
last_b = get_later_stmt (last_b, s);
else
last_b = stmtinfo_b;
return ((get_later_stmt (last_a, last_b) == last_a)
== (get_later_stmt (stmtinfo_a, stmtinfo_b) == stmtinfo_a));
} }
/* A subroutine of vect_analyze_data_ref_dependence. Handle /* A subroutine of vect_analyze_data_ref_dependence. Handle
......
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