From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-optimization/106722 - fix CD-DCE edge marking
Date: Fri, 10 Feb 2023 22:16:36 +0100 [thread overview]
Message-ID: <Y+a0NCqLOX1WpiWR@kam.mff.cuni.cz> (raw)
> The following fixes a latent issue when we mark control edges but
> end up with marking a block with no stmts necessary. In this case
> we fail to mark dependent control edges of that block.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> Does this look OK?
>
> Thanks,
> Richard.
>
> PR tree-optimization/106722
> * tree-ssa-dce.cc (mark_last_stmt_necessary): Return
> whether we marked a stmt.
> (mark_control_dependent_edges_necessary): When
> mark_last_stmt_necessary didn't mark any stmt make sure
> to mark its control dependent edges.
> (propagate_necessity): Likewise.
>
> * gcc.dg/torture/pr108737.c: New testcase.
> diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
> index b2fe9f4f55e..21b3294fc86 100644
> --- a/gcc/tree-ssa-dce.cc
> +++ b/gcc/tree-ssa-dce.cc
> @@ -327,17 +327,23 @@ mark_stmt_if_obviously_necessary (gimple *stmt, bool aggressive)
>
> /* Mark the last statement of BB as necessary. */
>
> -static void
> +static bool
> mark_last_stmt_necessary (basic_block bb)
> {
> gimple *stmt = last_stmt (bb);
>
> - bitmap_set_bit (last_stmt_necessary, bb->index);
> + if (!bitmap_set_bit (last_stmt_necessary, bb->index))
> + return true;
> +
> bitmap_set_bit (bb_contains_live_stmts, bb->index);
>
> /* We actually mark the statement only if it is a control statement. */
> if (stmt && is_ctrl_stmt (stmt))
> - mark_stmt_necessary (stmt, true);
> + {
> + mark_stmt_necessary (stmt, true);
> + return true;
> + }
> + return false;
> }
>
>
> @@ -369,8 +375,8 @@ mark_control_dependent_edges_necessary (basic_block bb, bool ignore_self)
> continue;
> }
>
> - if (!bitmap_bit_p (last_stmt_necessary, cd_bb->index))
> - mark_last_stmt_necessary (cd_bb);
> + if (!mark_last_stmt_necessary (cd_bb))
> + mark_control_dependent_edges_necessary (cd_bb, false);
Makes sense to me, though I am bit surprised it took such a long time to
show up.
Honza
next reply other threads:[~2023-02-10 21:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 21:16 Jan Hubicka [this message]
[not found] <20230210101245.1440C385B514@sourceware.org>
2023-02-13 14:42 ` Jeff Law
-- strict thread matches above, loose matches on Subject: below --
2023-02-10 10:12 Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+a0NCqLOX1WpiWR@kam.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).