From: Jakub Jelinek Date: Mon, 25 Jun 2018 17:11:05 +0000 (+0200) Subject: backport: re PR tree-optimization/83605 (ICE: verify_gimple failed (error: dead STMT... X-Git-Tag: releases/gcc-6.5.0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=799b606a5a11512a593fd2f04ce0840ef0f510fc;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/83605 (ICE: verify_gimple failed (error: dead STMT in EH table)) Backported from mainline 2018-01-05 Jakub Jelinek PR tree-optimization/83605 * gimple-ssa-strength-reduction.c: Include tree-eh.h. (find_candidates_dom_walker::before_dom_children): Ignore stmts that can throw. * gcc.dg/pr83605.c: New test. From-SVN: r262052 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e88bcc28aa12..16e5b1a06f17 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,13 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-01-05 Jakub Jelinek + + PR tree-optimization/83605 + * gimple-ssa-strength-reduction.c: Include tree-eh.h. + (find_candidates_dom_walker::before_dom_children): Ignore stmts that + can throw. + 2017-12-23 Jakub Jelinek PR c++/83553 diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 46bce1c4b0ef..4868d3a2eb57 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-ssa-address.h" #include "tree-affine.h" +#include "tree-eh.h" #include "builtins.h" /* Information about a strength reduction candidate. Each statement @@ -1701,6 +1702,9 @@ find_candidates_dom_walker::before_dom_children (basic_block bb) { gimple *gs = gsi_stmt (gsi); + if (stmt_could_throw_p (gs)) + continue; + if (gimple_vuse (gs) && gimple_assign_single_p (gs)) slsr_process_ref (gs); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8bc2fb9088cd..dde03d6687bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-01-05 Jakub Jelinek + + PR tree-optimization/83605 + * gcc.dg/pr83605.c: New test. + 2017-12-23 Jakub Jelinek PR c++/83553 diff --git a/gcc/testsuite/gcc.dg/pr83605.c b/gcc/testsuite/gcc.dg/pr83605.c new file mode 100644 index 000000000000..c680f0ce91f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83605.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/83605 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftrapv -fexceptions -fnon-call-exceptions" } */ + +int a; + +int +foo (int x) +{ + int b = a; + { + int c; + int *d = (x == 0) ? &c : &b; + + for (a = 0; a < 2; ++a) + c = (x + b) < a; + + return *d; + } +}