Hi, The attached patch tries to fix PR92163 by calling gimple_purge_dead_eh_edges from ifcvt_local_dce if we need eh cleanup. Does it look OK ?
Thanks, Prathamesh
2019-10-24 Prathamesh Kulkarni <prathamesh.kulka...@linaro.org> PR tree-optimization/92163 * tree-if-conv.c (ifcvt_local_dce): Call gimple_purge_dead_eh_edges if eh cleanup is required. * tree-ssa-dse.c (delete_dead_or_redundant_assignment): Change return type to bool and return the return value of gsi_remove. * tree-ssa-dse.h (delete_dead_or_redundant_assignment): Adjust prototype. testsuite/ * gcc.dg/tree-ssa/pr92163.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr92163.c b/gcc/testsuite/gcc.dg/tree-ssa/pr92163.c new file mode 100644 index 00000000000..f64eaea6517 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr92163.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fopenacc" } */ + +void +xr (int *k7) +{ + int qa; + +#pragma acc parallel +#pragma acc loop vector + for (qa = 0; qa < 3; ++qa) + if (qa % 2 != 0) + k7[qa] = 0; + else + k7[qa] = 1; +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index df9046a3014..3e2769dd02d 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2963,6 +2963,7 @@ ifcvt_local_dce (class loop *loop) } } /* Delete dead statements. */ + bool do_eh_cleanup = false; gsi = gsi_start_bb (bb); while (!gsi_end_p (gsi)) { @@ -2975,7 +2976,7 @@ ifcvt_local_dce (class loop *loop) if (dse_classify_store (&write, stmt, false, NULL, NULL, latch_vdef) == DSE_STORE_DEAD) - delete_dead_or_redundant_assignment (&gsi, "dead"); + do_eh_cleanup |= delete_dead_or_redundant_assignment (&gsi, "dead"); else gsi_next (&gsi); continue; @@ -2994,6 +2995,9 @@ ifcvt_local_dce (class loop *loop) gsi_remove (&gsi, true); release_defs (stmt); } + + if (do_eh_cleanup) + gimple_purge_dead_eh_edges (bb); } /* If-convert LOOP when it is legal. For the moment this pass has no diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 25cd4709b31..deec6c07c50 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -77,7 +77,6 @@ along with GCC; see the file COPYING3. If not see fact, they are the same transformation applied to different views of the CFG. */ -void delete_dead_or_redundant_assignment (gimple_stmt_iterator *, const char *); static void delete_dead_or_redundant_call (gimple_stmt_iterator *, const char *); /* Bitmap of blocks that have had EH statements cleaned. We should @@ -899,7 +898,7 @@ delete_dead_or_redundant_call (gimple_stmt_iterator *gsi, const char *type) /* Delete a dead store at GSI, which is a gimple assignment. */ -void +bool delete_dead_or_redundant_assignment (gimple_stmt_iterator *gsi, const char *type) { gimple *stmt = gsi_stmt (*gsi); @@ -915,12 +914,14 @@ delete_dead_or_redundant_assignment (gimple_stmt_iterator *gsi, const char *type /* Remove the dead store. */ basic_block bb = gimple_bb (stmt); - if (gsi_remove (gsi, true)) + bool eh_cleanup_required = gsi_remove (gsi, true); + if (eh_cleanup_required && need_eh_cleanup) bitmap_set_bit (need_eh_cleanup, bb->index); /* And release any SSA_NAMEs set in this statement back to the SSA_NAME manager. */ release_defs (stmt); + return eh_cleanup_required; } /* Attempt to eliminate dead stores in the statement referenced by BSI. diff --git a/gcc/tree-ssa-dse.h b/gcc/tree-ssa-dse.h index a5eccbd746d..80b6d9b2616 100644 --- a/gcc/tree-ssa-dse.h +++ b/gcc/tree-ssa-dse.h @@ -31,6 +31,6 @@ enum dse_store_status dse_store_status dse_classify_store (ao_ref *, gimple *, bool, sbitmap, bool * = NULL, tree = NULL); -void delete_dead_or_redundant_assignment (gimple_stmt_iterator *, const char *); +bool delete_dead_or_redundant_assignment (gimple_stmt_iterator *, const char *); #endif /* GCC_TREE_SSA_DSE_H */