diff options
author | Richard Biener <rguenther@suse.de> | 2017-01-17 08:38:59 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-01-17 08:38:59 +0000 |
commit | 12314dc98976f0dc987ec8081e4672b76507e46e (patch) | |
tree | e122e9f887592491b3c316c026bf3457db280f07 /gcc/tree-vrp.c | |
parent | a23e48df4514c4f40e832f196b1b50b1e5010bd2 (diff) | |
download | gcc-12314dc98976f0dc987ec8081e4672b76507e46e.zip gcc-12314dc98976f0dc987ec8081e4672b76507e46e.tar.gz gcc-12314dc98976f0dc987ec8081e4672b76507e46e.tar.bz2 |
re PR tree-optimization/71433 (-Warray-bounds false positive with -O2)
2017-01-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/71433
* tree-vrp.c (register_new_assert_for): Merge same asserts
on all incoming edges.
(process_assert_insertions_for): Handle insertions at the
beginning of BBs.
* gcc.dg/Warray-bounds-20.c: New testcase.
From-SVN: r244520
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 4cfdd0a..ac37d3f 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5032,6 +5032,17 @@ register_new_assert_for (tree name, tree expr, loc->si = si; return; } + /* If we have the same assertion on all incoming edges of a BB + instead insert it at the beginning of it. */ + if (e && loc->e + && dest_bb == loc->e->dest + && EDGE_COUNT (dest_bb->preds) == 2) + { + loc->bb = dest_bb; + loc->e = NULL; + loc->si = gsi_none (); + return; + } } /* Update the last node of the list and move to the next one. */ @@ -6429,6 +6440,15 @@ process_assert_insertions_for (tree name, assert_locus *loc) return true; } + /* If the stmt iterator points at the end then this is an insertion + at the beginning of a block. */ + if (gsi_end_p (loc->si)) + { + gimple_stmt_iterator si = gsi_after_labels (loc->bb); + gsi_insert_before (&si, assert_stmt, GSI_SAME_STMT); + return false; + + } /* Otherwise, we can insert right after LOC->SI iff the statement must not be the last statement in the block. */ stmt = gsi_stmt (loc->si); |