From 06f9708454a5e644b1fb5ed17a863cd624985e17 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 6 Dec 2017 20:27:41 +0100 Subject: [PATCH] re PR tree-optimization/83293 (ICE: in gsi_insert_seq_nodes_after, at gimple-iterator.c:278) PR tree-optimization/83293 * gimple-ssa-strength-reduction.c (insert_initializers): Use GSI_NEW_STMT instead of GSI_SAME_STMT in gsi_insert_after that might insert into empty bb. * g++.dg/torture/pr83293.C: New test. From-SVN: r255451 --- gcc/ChangeLog | 5 ++++ gcc/gimple-ssa-strength-reduction.c | 2 +- gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/g++.dg/torture/pr83293.C | 39 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr83293.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9cfc382239b..0310a5202d8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-12-06 Jakub Jelinek + PR tree-optimization/83293 + * gimple-ssa-strength-reduction.c (insert_initializers): Use + GSI_NEW_STMT instead of GSI_SAME_STMT in gsi_insert_after that + might insert into empty bb. + PR sanitizer/81281 * match.pd ((T)(P + A) - (T)P -> (T) A): Split into separate simplify for plus with :c added, and pointer_plus without that. diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 42320ff6682..b51239b94d0 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -3418,7 +3418,7 @@ insert_initializers (slsr_cand_t c) gsi_insert_after (&gsi, cast_stmt, GSI_NEW_STMT); gimple_set_location (cast_stmt, loc); } - gsi_insert_after (&gsi, init_stmt, GSI_SAME_STMT); + gsi_insert_after (&gsi, init_stmt, GSI_NEW_STMT); } gimple_set_location (init_stmt, gimple_location (basis_stmt)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ad19f056ec..67bdbbd5b33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-12-06 Jakub Jelinek + PR tree-optimization/83293 + * g++.dg/torture/pr83293.C: New test. + PR sanitizer/81281 * gcc.c-torture/execute/pr81281.c: New test. * gcc.dg/pr81281-1.c: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr83293.C b/gcc/testsuite/g++.dg/torture/pr83293.C new file mode 100644 index 00000000000..f4556f3ee52 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr83293.C @@ -0,0 +1,39 @@ +// PR tree-optimization/83293 + +typedef __SIZE_TYPE__ size_t; +template struct A { + T a; + A (T x) : a(x) {} + T foo () { return a; } +}; + +template +int +operator==(A x, A p2) +{ + return x.foo () == p2.foo (); +} + +struct B { struct { int *b, *c; } d; }; +struct C : B { + A bar () { return d.b; } + A baz () { return d.c; } + size_t boo () { return d.c - d.b; } + int zoo () { return bar () == baz (); } +}; +struct D { C e; } a; +size_t b; + +size_t +test (int x) +{ + size_t c (x * b); + if (!a.e.zoo ()) + { + x += 2; + for (size_t d = 0, e = a.e.boo (); d < e; ++d) + c += test (0); + } + c += (x - 1) * b; + return c; +} -- 2.30.2