public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH 5/7] PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt
Date: Mon, 24 Apr 2023 14:30:09 -0700	[thread overview]
Message-ID: <20230424213011.528181-6-apinski@marvell.com> (raw)
In-Reply-To: <20230424213011.528181-1-apinski@marvell.com>

In the early PHIOPT mode, the original minmax_replacement, would
replace a PHI node with up to 2 min/max expressions in some cases,
this allows for that too.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (phiopt_early_allow): Allow for
	up to 2 min/max expressions in the sequence/match code.
---
 gcc/tree-ssa-phiopt.cc | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index fb2d2c9fc1a..de1896aa91a 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -542,9 +542,23 @@ phiopt_early_allow (gimple_seq &seq, gimple_match_op &op)
     return false;
   tree_code code = (tree_code)op.code;
 
-  /* For non-empty sequence, only allow one statement.  */
+  /* For non-empty sequence, only allow one statement
+     except for MIN/MAX, allow max 2 statements,
+     each with MIN/MAX.  */
   if (!gimple_seq_empty_p (seq))
     {
+      if (code == MIN_EXPR || code == MAX_EXPR)
+	{
+	  if (!gimple_seq_singleton_p (seq))
+	    return false;
+
+	  gimple *stmt = gimple_seq_first_stmt (seq);
+	  /* Only allow assignments.  */
+	  if (!is_gimple_assign (stmt))
+	    return false;
+	  code = gimple_assign_rhs_code (stmt);
+	  return code == MIN_EXPR || code == MAX_EXPR;
+	}
       /* Check to make sure op was already a SSA_NAME.  */
       if (code != SSA_NAME)
 	return false;
-- 
2.39.1


  parent reply	other threads:[~2023-04-24 21:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 21:30 [PATCH 0/7] Some more phiopt cleanups and double minmax to match Andrew Pinski
2023-04-24 21:30 ` [PATCH 1/7] PHIOPT: Split out store elimination from phiopt Andrew Pinski
2023-04-27 10:50   ` Richard Biener
2023-04-24 21:30 ` [PATCH 2/7] PHIOPT: Rename tree_ssa_phiopt_worker to pass_phiopt::execute Andrew Pinski
2023-04-27 10:58   ` Richard Biener
2023-04-24 21:30 ` [PATCH 3/7] PHIOPT: Move store_elim_worker into pass_cselim::execute Andrew Pinski
2023-04-27 10:50   ` Richard Biener
2023-04-24 21:30 ` [PATCH 4/7] MIN/MAX should be treated similar as comparisons for trapping Andrew Pinski
2023-04-27 10:49   ` Richard Biener
2023-04-24 21:30 ` Andrew Pinski [this message]
2023-04-27 10:51   ` [PATCH 5/7] PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt Richard Biener
2023-04-24 21:30 ` [PATCH 6/7] MATCH: Factor out code that for min max detection with constants Andrew Pinski
2023-04-25 10:45   ` Mikael Morin
2023-04-24 21:30 ` [PATCH 7/7] MATCH: Add patterns from phiopt's minmax_replacement Andrew Pinski
2023-04-27 10:58   ` 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=20230424213011.528181-6-apinski@marvell.com \
    --to=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).