public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/68894] Recognition min/max pattern with multiple arguments.
Date: Sun, 09 Apr 2023 23:50:14 +0000	[thread overview]
Message-ID: <bug-68894-4-5X83vB7e4a@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-68894-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68894

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #7)
> Mine, working on improving phi-opt here; though the hoisting of the load is
> something which needs to be looked into further.
> 
> I have the match.pd pattern for what is mentioned in comment #3:
> /* These was part of minmax phiopt.  */
> /* Optimize (a CMP b) ? minmax<a, c> : minmax<b, c>
>    to minmax<min/max<a, b>, c> */
> (for minmax (min max)
>  (for cmp (lt le gt ge)
>   (simplify
>    (cond (cmp @1 @3) (minmax:c @1 @4) (minmax:c @2 @4))
>    (with
>     {
>       tree_code code = minmax_from_comparison (cmp, @1, @2, @1, @3);
>     }
>     (if (code == MIN_EXPR)
>      (minmax (min @1 @2) @4)
>      (if (code == MAX_EXPR)
>       (minmax (max @1 @2) @4)))))))
> 
> I also have the improvements to match_simplify_replacement which are needed
> to use those patterns too. I will be submitting them for GCC 14.

Note these patterns are enough for the ifcvt pass for the vectorizer to
generate:

  pretmp_24 = a3D.2740[i_20];
  _35 = MIN_EXPR <_1, _2>;
  d_9 = MIN_EXPR <pretmp_24, _35>;

Rather than the current:

  d_14 = MIN_EXPR <_1, pretmp_24>;
  _23 = _1 < _2;
  d_13 = MIN_EXPR <_2, pretmp_24>;
  d_9 = _23 ? d_14 : d_13;

  parent reply	other threads:[~2023-04-09 23:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-68894-4@http.gcc.gnu.org/bugzilla/>
2023-04-09 23:33 ` pinskia at gcc dot gnu.org
2023-04-09 23:50 ` pinskia at gcc dot gnu.org [this message]
2023-04-10 22:11 ` pinskia at gcc dot gnu.org
2023-04-24 15:50 ` cvs-commit at gcc dot gnu.org
2023-04-24 15:57 ` pinskia at gcc dot gnu.org
2023-04-24 19:06 ` pinskia at gcc dot gnu.org
2023-04-28 14:55 ` pinskia at gcc dot gnu.org

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=bug-68894-4-5X83vB7e4a@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).