diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0796cda55b6..f52e26008a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-07-03 Tom de Vries + + backport from mainline: + PR tree-optimization/81192 + 2017-07-03 Tom de Vries + + * tree-ssa-tail-merge.c (same_succ_flush_bb): Handle + BB_SAME_SUCC (bb) == NULL. + 2017-06-29 Michael Meissner Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c0235104fc..6b7ed023f33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-07-03 Tom de Vries + + backport from mainline: + PR tree-optimization/81192 + 2017-07-03 Tom de Vries + + * gcc.dg/pr81192.c: New test. + 2017-06-29 Michael Meissner Backport from mainline diff --git a/gcc/testsuite/gcc.dg/pr81192.c b/gcc/testsuite/gcc.dg/pr81192.c new file mode 100644 index 00000000000..57eb4781d4d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81192.c @@ -0,0 +1,22 @@ +/* { dg-options "-Os -fdump-tree-pre-details" } */ + +unsigned a; +int b, c; + +static int +fn1 (int p1, int p2) +{ + return p1 > 2147483647 - p2 ? p1 : p1 + p2; +} + +void +fn2 (void) +{ + int j; + a = 30; + for (; a;) + for (; c; b = fn1 (j, 1)) + ; +} + +/* { dg-final { scan-tree-dump-times "(?n)find_duplicates: duplicate of " 1 "pre" } } */ diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index 71f874d3123..01c25d43e0d 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -808,6 +808,9 @@ static void same_succ_flush_bb (basic_block bb) { same_succ *same = BB_SAME_SUCC (bb); + if (! same) + return; + BB_SAME_SUCC (bb) = NULL; if (bitmap_single_bit_set_p (same->bbs)) same_succ_htab->remove_elt_with_hash (same, same->hashval);