diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-15 09:38:54 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-12-01 14:59:51 +0100 |
commit | 3d0da0bc398054f2c37f09b13ccf7e2e2ef63b22 (patch) | |
tree | a9a8ea38b1491a69ab1e5fef86f105ef35319d28 /gcc | |
parent | 427fe143a43ba13497759e1482ce683deed9a00b (diff) | |
download | gcc-3d0da0bc398054f2c37f09b13ccf7e2e2ef63b22.zip gcc-3d0da0bc398054f2c37f09b13ccf7e2e2ef63b22.tar.gz gcc-3d0da0bc398054f2c37f09b13ccf7e2e2ef63b22.tar.bz2 |
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 <rguenther@suse.de>
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.
(cherry picked from commit aaf1ee48316f9b414b11c17e298198925d816595)
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-ssa-split-paths.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr95133.c | 14 |
2 files changed, 22 insertions, 2 deletions
diff --git a/gcc/gimple-ssa-split-paths.c b/gcc/gimple-ssa-split-paths.c index a851511..caf8f94 100644 --- a/gcc/gimple-ssa-split-paths.c +++ b/gcc/gimple-ssa-split-paths.c @@ -68,8 +68,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/gcc.dg/pr95133.c b/gcc/testsuite/gcc.dg/pr95133.c new file mode 100644 index 0000000..523deca --- /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); +} |