diff options
author | Richard Biener <rguenther@suse.de> | 2017-03-06 13:58:01 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-03-06 13:58:01 +0000 |
commit | 522fcdd739e5cc24bd8392f5c00dd5b439804c36 (patch) | |
tree | 45d204024fc3cb6ab2165a7431d5a081d8b7aa2b /gcc/tree-vect-stmts.c | |
parent | 5464963112924aa64a0e82cd856275e2faa66436 (diff) | |
download | gcc-522fcdd739e5cc24bd8392f5c00dd5b439804c36.zip gcc-522fcdd739e5cc24bd8392f5c00dd5b439804c36.tar.gz gcc-522fcdd739e5cc24bd8392f5c00dd5b439804c36.tar.bz2 |
re PR tree-optimization/79824 (Failure to peel for gaps leads to read beyond mapped memory)
2017-03-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/79824
* tree-vect-stmts.c (get_group_load_store_type): Fix alignment
check disabling peeling for gaps.
* gcc.dg/vect/pr79824-1.c: New testcase.
* gcc.dg/vect/pr79824-2.c: Likewise.
From-SVN: r245922
Diffstat (limited to 'gcc/tree-vect-stmts.c')
-rw-r--r-- | gcc/tree-vect-stmts.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index c87f72c..9f28321 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1731,7 +1731,7 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp, bool single_element_p = (stmt == first_stmt && !GROUP_NEXT_ELEMENT (stmt_info)); unsigned HOST_WIDE_INT gap = GROUP_GAP (vinfo_for_stmt (first_stmt)); - int nunits = TYPE_VECTOR_SUBPARTS (vectype); + unsigned nunits = TYPE_VECTOR_SUBPARTS (vectype); /* True if the vectorized statements would access beyond the last statement in the group. */ @@ -1794,9 +1794,13 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp, /* If there is a gap at the end of the group then these optimizations would access excess elements in the last iteration. */ bool would_overrun_p = (gap != 0); - /* If the access is aligned an overrun is fine. */ + /* If the access is aligned an overrun is fine, but only if the + overrun is not inside an unused vector (if the gap is as large + or larger than a vector). */ if (would_overrun_p - && aligned_access_p (STMT_VINFO_DATA_REF (stmt_info))) + && gap < nunits + && aligned_access_p + (STMT_VINFO_DATA_REF (vinfo_for_stmt (first_stmt)))) would_overrun_p = false; if (!STMT_VINFO_STRIDED_P (stmt_info) && (can_overrun_p || !would_overrun_p) |