https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385
--- Comment #24 from rguenther at suse dot de <rguenther at suse dot de> --- On April 17, 2020 3:53:07 PM GMT+02:00, "jakub at gcc dot gnu.org" <gcc-bugzi...@gcc.gnu.org> wrote: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93385 > >--- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> --- >Instead of #c11 I meant: >- else if ((is_gimple_assign (stmt) && !gimple_has_volatile_ops >(stmt)) >- || gimple_code (stmt) == GIMPLE_PHI) >+ else if (flag_tree_dce >+ && ((is_gimple_assign (stmt) && >!gimple_has_volatile_ops >(stmt)) >+ || gimple_code (stmt) == GIMPLE_PHI)) >because the res = -1 handling is in the else after this already. > >For what Richi is proposing, I guess one needs to run the analysis >somewhere >(early tree_function_versioning or elsewhere?, note in a hash_set stmts >that >shouldn't be copied, add pointer to that hash_set to copy_body_data and >perhaps >in remap_gimple_stmt if the hash_set pointer is non-NULL, check early >if stmt >is in it and in that case return NULL (like we already return NULL for >debug >stmts if we want to drop them). >Most likely the lhs of such to be removed statements need to be also >added to >id.killed_new_ssa_names (and verify if it works properly). I'd definitely make sure to map supposed to be DCEd defs to error_mark_node. For the marking one could add id.plf_to_dce and clear/set the plf on the stmts.