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/107888] [12/13 Regression] Missed min/max transformation in phiopt due to VRP
Date: Mon, 28 Nov 2022 17:26:55 +0000	[thread overview]
Message-ID: <bug-107888-4-EADSk1m9eC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107888-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> which means we fail to optimize a > b ? 1 : b as well, no?

Yes that is correct.

Even for max, "a >= b ? a : 6;" would need to be "reverted" 6 back to b.

  <bb 5> [local count: 1073741824]:
  if (ab_2(D) >= bb_3(D))
    goto <bb 6>; [65.00%]
  else
    goto <bb 7>; [35.00%]

  <bb 6> [local count: 697932184]:

  <bb 7> [local count: 1073741824]:
  # c_1 = PHI <ab_2(D)(6), 6(5)>


The min/max patterns inside match needs to handle CST if the ranges of the two
operands overlap with one/two values.

Even though this is a regression, I don't know if this shows up in real code
and is a small optimization really so I would suspect a P4 for this really as
it requires a bigger change that most likely won't be backported. I filed it as
it was showing up while I was working on the patch for PR 101805 (which won't
be submitted until GCC 14 anyways).

  parent reply	other threads:[~2022-11-28 17:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 19:28 [Bug tree-optimization/107888] New: " pinskia at gcc dot gnu.org
2022-11-28  7:57 ` [Bug tree-optimization/107888] " rguenth at gcc dot gnu.org
2022-11-28 17:26 ` pinskia at gcc dot gnu.org [this message]
2022-12-21 13:35 ` rguenth at gcc dot gnu.org
2023-05-06  0:38 ` [Bug tree-optimization/107888] [12/13/14 " pinskia at gcc dot gnu.org
2023-05-08  5:35 ` pinskia at gcc dot gnu.org
2023-05-08 12:26 ` rguenth at gcc dot gnu.org
2023-05-09 10:14 ` pinskia at gcc dot gnu.org
2023-05-09 10:19 ` pinskia at gcc dot gnu.org
2023-05-10 18:11 ` pinskia at gcc dot gnu.org
2023-05-10 19:10 ` pinskia at gcc dot gnu.org
2023-05-16  3:50 ` cvs-commit 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-107888-4-EADSk1m9eC@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).