From cffcafda6a42033a18ed8eab86ef34b867eaae1e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 23 Jan 2017 13:08:44 +0000 Subject: [PATCH] re PR tree-optimization/79186 (ICE on valid code at -O2 and -O3 on x86_64-linux-gnu: Segmentation fault (in VRP)) 2017-01-23 Richard Biener PR tree-optimization/79186 * tree-vrp.c (register_new_assert_for): Make sure we've seen both incoming edges before moving an assert. * gcc.dg/torture/pr79186.c: New testcase. * gcc.dg/torture/pr79187.c: Likewise. From-SVN: r244804 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/torture/pr79186.c | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr79187.c | 19 +++++++++++++++++++ gcc/tree-vrp.c | 1 + 5 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr79186.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr79187.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ade7c76e27..71aaad9bcc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-23 Richard Biener + + PR tree-optimization/79186 + * tree-vrp.c (register_new_assert_for): Make sure we've seen + both incoming edges before moving an assert. + 2017-01-23 Martin Jambor * ipa-prop.c (load_from_param_1): Removed. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d53090552ac..c64baf573e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-01-23 Richard Biener + + PR tree-optimization/79186 + * gcc.dg/torture/pr79186.c: New testcase. + * gcc.dg/torture/pr79187.c: Likewise. + 2017-01-23 Martin Jambor * gcc.dg/ipa/vrp8.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr79186.c b/gcc/testsuite/gcc.dg/torture/pr79186.c new file mode 100644 index 00000000000..cefbe396800 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr79186.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +int a, b; +unsigned char c, d, e; + +int main () +{ + if (b || !a) + { + c = a; + if (!c && !a) + d = 0; + e = -a; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr79187.c b/gcc/testsuite/gcc.dg/torture/pr79187.c new file mode 100644 index 00000000000..b310a02d6cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr79187.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +int printf (const char *, ...); + +int a, b = -600, c, d[] = { 0 }, e, f, g = -1, h; +unsigned i = ~0; + +int main () +{ + for (; h < 2; h++) + { + if (a > 0) + printf ("%d\n", d[b]); + f = ~(b % i); + c = g | (f && g) && e | b; + a = ~(~g & b); + } + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index ac37d3f6e14..d7d7a0d3a08 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5035,6 +5035,7 @@ register_new_assert_for (tree name, tree expr, /* 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 + && e != loc->e && dest_bb == loc->e->dest && EDGE_COUNT (dest_bb->preds) == 2) { -- 2.30.2