From aaf1ee48316f9b414b11c17e298198925d816595 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 15 May 2020 09:38:54 +0200 Subject: [PATCH] tree-optimization/95133 - avoid abnormal edges in path splitting When path splitting tries to detect a CFG diamond make sure it is composed of normal (non-EH, not abnormal) edges. Otherwise CFG manipulation later may fail. 2020-05-15 Richard Biener PR tree-optimization/95133 * gimple-ssa-split-paths.c (find_block_to_duplicate_for_splitting_paths): Check for normal edges. * gcc.dg/pr95133.c: New testcase. --- gcc/ChangeLog | 7 +++++++ gcc/gimple-ssa-split-paths.c | 10 ++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr95133.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr95133.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fb7ee99fa28..b66cb8a477b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2020-05-15 Richard Biener + + PR tree-optimization/95133 + * gimple-ssa-split-paths.c + (find_block_to_duplicate_for_splitting_paths): Check for + normal edges. + 2020-05-15 Christophe Lyon * config/arm/arm.c (reg_needs_saving_p): Add support for interrupt diff --git a/gcc/gimple-ssa-split-paths.c b/gcc/gimple-ssa-split-paths.c index 1a56868f6a3..b3efd43c7ef 100644 --- a/gcc/gimple-ssa-split-paths.c +++ b/gcc/gimple-ssa-split-paths.c @@ -67,8 +67,14 @@ find_block_to_duplicate_for_splitting_paths (basic_block latch) region. Verify that it is. First, verify that BB has two predecessors (each arm of the - IF-THEN-ELSE) and two successors (the latch and exit). */ - if (EDGE_COUNT (bb->preds) == 2 && EDGE_COUNT (bb->succs) == 2) + IF-THEN-ELSE) and two successors (the latch and exit) and that + all edges are normal. */ + if (EDGE_COUNT (bb->preds) == 2 + && !(EDGE_PRED (bb, 0)->flags & EDGE_COMPLEX) + && !(EDGE_PRED (bb, 1)->flags & EDGE_COMPLEX) + && EDGE_COUNT (bb->succs) == 2 + && !(EDGE_SUCC (bb, 0)->flags & EDGE_COMPLEX) + && !(EDGE_SUCC (bb, 1)->flags & EDGE_COMPLEX)) { /* Now verify that BB's immediate dominator ends in a conditional as well. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b8b52dae2e..0398bf23891 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-15 Richard Biener + + PR tree-optimization/95133 + * gcc.dg/pr95133.c: New testcase. + 2020-05-15 Tobias Burnus PR middle-end/94635 diff --git a/gcc/testsuite/gcc.dg/pr95133.c b/gcc/testsuite/gcc.dg/pr95133.c new file mode 100644 index 00000000000..523decaf90e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr95133.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +extern int a[16]; +void f (int *ip, int x) +{ + int *xp = a; + for (int i=0; i<8; ++i) + { + base: if (x) return; + } + *xp++ = *ip; + goto *(&&base + *ip); +}