On Thu, 14 Mar 2019, Richard Biener wrote: > On Thu, 14 Mar 2019, Jakub Jelinek wrote: > > > On Thu, Mar 14, 2019 at 11:23:03AM +0100, Richard Biener wrote: > > > I am testing the following. There's IMHO also a missed optimization > > > (for CFG-cleanup?) that when a block does not end up in a call > > > outgoing abnormal edges can be purged? In this case it is > > > IPA inlining leaving us with this - the inliner calls > > > gimple_purge_dead_abnormal_call_edges on the return block > > > but both cfun->has_nonlocal_label and cfun->calls_setjmp are > > > false so the function does nothing. This is probably > > > a premature check there? > > > > I think it would be better to keep the invariant that there are no abnormal > > non-EH edges if both of the cfun bools are false, so that we don't need to > > do useless work in the 99.9% of cases. > > I agree. > > > In the inliner case, is it that we haven't yet updated those or something > > similar (if yes, could we update them earlier)? > > It's the edge still being present when DCE recomputes the flag. > > > In the DCE case, can't we when clearing the flag schedule a cleanup and only > > clear it afterwards? > > Well, I guess the cleanup would just work iff we'd keep the flag > check in call_can_make_abnormal_goto but remove the flag check > in gimple_purge_dead_abnormal_call_edges. Not immediately > after DCE but at least inlining gets rid of the edge (and the > abnormal dispatcher) then. > > Does that sound reasonable? > > Thus like the following, testing in progress.
I've added a testcase. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK for trunk or should it wait for GCC10? Thanks, Richard. 2019-03-14 Richard Biener <rguent...@suse.de> PR tree-optimization/89710 * tree-cfg.c (gimple_purge_dead_abnormal_call_edges): Remove premature check. * gcc.dg/tree-ssa/pr89710.c: New testcase. Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 269678) +++ gcc/tree-cfg.c (working copy) @@ -8714,10 +8714,6 @@ gimple_purge_dead_abnormal_call_edges (b edge_iterator ei; gimple *stmt = last_stmt (bb); - if (!cfun->has_nonlocal_label - && !cfun->calls_setjmp) - return false; - if (stmt && stmt_can_make_abnormal_goto (stmt)) return false; Index: gcc/testsuite/gcc.dg/tree-ssa/pr89710.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr89710.c (nonexistent) +++ gcc/testsuite/gcc.dg/tree-ssa/pr89710.c (working copy) @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fixup_cfg3" } */ + +void +gm (int *); + +__attribute__ ((returns_twice)) void +jg (void) +{ +} + +void +eb (void) +{ + int r6 = 0; + + if (r6 != 0) + gm (&r6); +} + +void +gm (int *r6) +{ + jg (); + + for (;;) + { + eb (); + *r6 = 0; + } +} + +/* After IPA inlining all abnormal edges and the dispatcher should vanish. */ +/* { dg-final { scan-tree-dump-not "ABNORMAL_DISPATCHER" "fixup_cfg3" } } */