From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 5/6] PHIOPT: Ignore predicates for match-and-simplify phi-opt
Date: Mon, 24 Apr 2023 14:05:19 +0200 [thread overview]
Message-ID: <CAFiYyc1tvTNjX5yOGfbsS6NBaVzDOCgw5O4gHZ_Rif8ypehTzw@mail.gmail.com> (raw)
In-Reply-To: <20230422220921.452264-6-apinski@marvell.com>
On Sun, Apr 23, 2023 at 12:11 AM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This fixes a missed optimization where early phi-opt would
> not work when there was predicates. The easiest fix is
> to change empty_bb_or_one_feeding_into_p to ignore those
> statements while checking for only feeding statement.
>
> Note phi-opt-23.c and phi-opt-24.c still fail as we don't handle
> diamond form in match_and_simplify phiopt yet.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
OK.
> gcc/ChangeLog:
>
> * tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p):
> Instead of calling last_and_only_stmt, look for the last statement
> manually.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Add -fno-ssa-phiopt.
> ---
> .../gcc.dg/tree-ssa/ssa-ifcombine-13.c | 4 +++-
> gcc/tree-ssa-phiopt.cc | 22 +++++++++++++++++--
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c
> index 425eb3d6481..7976544c79b 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c
> @@ -1,5 +1,7 @@
> /* { dg-do compile } */
> -/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1" } */
> +/* Disable phi-opt as it is no longer confused by predicate which had allowed ifcombine to work in the past.
> + Note this testcase is about ifcombine rather than phi-opt. */
> +/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1 -fno-ssa-phiopt" } */
>
> _Bool f1(_Bool a, _Bool b)
> {
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index cb4d8788b56..ffd6a4e6f35 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -962,9 +962,27 @@ empty_bb_or_one_feeding_into_p (basic_block bb,
> if (!gimple_seq_empty_p (phi_nodes (bb)))
> return false;
>
> - stmt_to_move = last_and_only_stmt (bb);
> + gimple_stmt_iterator gsi;
> +
> + gsi = gsi_start_nondebug_after_labels_bb (bb);
> + while (!gsi_end_p (gsi))
> + {
> + gimple *s = gsi_stmt (gsi);
> + gsi_next_nondebug (&gsi);
> + /* Skip over Predict and nop statements. */
> + if (gimple_code (s) == GIMPLE_PREDICT
> + || gimple_code (s) == GIMPLE_NOP)
> + continue;
> + /* If there is more one statement return false. */
> + if (stmt_to_move)
> + return false;
> + stmt_to_move = s;
> + }
> +
> + /* The only statement here was a Predict or a nop statement
> + so return true. */
> if (!stmt_to_move)
> - return false;
> + return true;
>
> if (gimple_vuse (stmt_to_move))
> return false;
> --
> 2.39.1
>
next prev parent reply other threads:[~2023-04-24 12:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 22:09 [PATCH 0/6] Improve PHIOPT match and simplify for diamond shaped bbs Andrew Pinski
2023-04-22 22:09 ` [PATCH 1/6] PHIOPT: Move check on diamond bb to tree_ssa_phiopt_worker from minmax_replacement Andrew Pinski
2023-04-24 12:01 ` Richard Biener
2023-04-22 22:09 ` [PATCH 2/6] PHIOPT: Cleanup tree_ssa_phiopt_worker code Andrew Pinski
2023-04-24 12:06 ` Richard Biener
2023-04-22 22:09 ` [PATCH 3/6] PHIOPT: Allow other diamond uses when do_hoist_loads is true Andrew Pinski
2023-04-24 12:06 ` Richard Biener
2023-04-22 22:09 ` [PATCH 4/6] PHIOPT: Factor out some code from match_simplify_replacement Andrew Pinski
2023-04-24 12:02 ` Richard Biener
2023-04-22 22:09 ` [PATCH 5/6] PHIOPT: Ignore predicates for match-and-simplify phi-opt Andrew Pinski
2023-04-24 12:05 ` Richard Biener [this message]
2023-04-22 22:09 ` [PATCH 6/6] PHIOPT: Add support for diamond shaped bb to match_simplify_replacement Andrew Pinski
2023-04-24 12:07 ` 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=CAFiYyc1tvTNjX5yOGfbsS6NBaVzDOCgw5O4gHZ_Rif8ypehTzw@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=apinski@marvell.com \
--cc=gcc-patches@gcc.gnu.org \
/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).