summaryrefslogtreecommitdiff
path: root/gcc/tree-vect-data-refs.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2014-01-29 10:27:43 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2014-01-29 10:27:43 +0100
commit3d54b29d70cca0ae952f3fed9423c3acb28778a5 (patch)
treeb0698b0296f9eb4ef904fa94a9c111824180346b /gcc/tree-vect-data-refs.c
parent15b31f8c7e139e3799cba19e61c636eb4b3fccc1 (diff)
downloadgcc-3d54b29d70cca0ae952f3fed9423c3acb28778a5.tar.gz
re PR tree-optimization/59594 (wrong code (by tree vectorizer) at -O3 on x86_64-linux-gnu)
PR tree-optimization/59594 * tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Sort a copy of the datarefs vector rather than the vector itself. * gcc.dg/vect/no-vfa-vect-depend-2.c: New test. * gcc.dg/vect/no-vfa-vect-depend-3.c: New test. * gcc.dg/vect/pr59594.c: New test. From-SVN: r207225
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r--gcc/tree-vect-data-refs.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 0deac8177fd..c3e8f372b83 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -2484,19 +2484,21 @@ vect_analyze_data_ref_accesses (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
return true;
/* Sort the array of datarefs to make building the interleaving chains
- linear. */
- qsort (datarefs.address (), datarefs.length (),
+ linear. Don't modify the original vector's order, it is needed for
+ determining what dependencies are reversed. */
+ vec<data_reference_p> datarefs_copy = datarefs.copy ();
+ qsort (datarefs_copy.address (), datarefs_copy.length (),
sizeof (data_reference_p), dr_group_sort_cmp);
/* Build the interleaving chains. */
- for (i = 0; i < datarefs.length () - 1;)
+ for (i = 0; i < datarefs_copy.length () - 1;)
{
- data_reference_p dra = datarefs[i];
+ data_reference_p dra = datarefs_copy[i];
stmt_vec_info stmtinfo_a = vinfo_for_stmt (DR_STMT (dra));
stmt_vec_info lastinfo = NULL;
- for (i = i + 1; i < datarefs.length (); ++i)
+ for (i = i + 1; i < datarefs_copy.length (); ++i)
{
- data_reference_p drb = datarefs[i];
+ data_reference_p drb = datarefs_copy[i];
stmt_vec_info stmtinfo_b = vinfo_for_stmt (DR_STMT (drb));
/* ??? Imperfect sorting (non-compatible types, non-modulo
@@ -2573,7 +2575,7 @@ vect_analyze_data_ref_accesses (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
}
}
- FOR_EACH_VEC_ELT (datarefs, i, dr)
+ FOR_EACH_VEC_ELT (datarefs_copy, i, dr)
if (STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr)))
&& !vect_analyze_data_ref_access (dr))
{
@@ -2588,9 +2590,13 @@ vect_analyze_data_ref_accesses (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
continue;
}
else
- return false;
+ {
+ datarefs_copy.release ();
+ return false;
+ }
}
+ datarefs_copy.release ();
return true;
}