public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/96480] [8/9/10/11 Regression] missed optimisation: unnecessary compare in standard algorithms
Date: Thu, 06 Aug 2020 13:48:23 +0000	[thread overview]
Message-ID: <bug-96480-4-xqchgAGiq4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96480-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:b3aa137212b1af0c824a9890eba2ca27a7271d56

commit r11-2593-gb3aa137212b1af0c824a9890eba2ca27a7271d56
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Aug 6 15:47:25 2020 +0200

    reassoc: Improve maybe_optimize_range_tests [PR96480]

    On the following testcase, if the IL before reassoc would be:
    ...
      <bb 4> [local count: 354334800]:
      if (x_3(D) == 2)
        goto <bb 7>; [34.00%]
      else
        goto <bb 5>; [66.00%]

      <bb 5> [local count: 233860967]:
      if (x_3(D) == 3)
        goto <bb 7>; [34.00%]
      else
        goto <bb 6>; [66.00%]

      <bb 6> [local count: 79512730]:

      <bb 7> [local count: 1073741824]:
      # prephitmp_7 = PHI <1(3), 1(4), 1(5), 1(2), 0(6)>
    then we'd optimize it properly, but as bb 5-7 is instead:
      <bb 5> [local count: 233860967]:
      if (x_3(D) == 3)
        goto <bb 6>; [34.00%]
      else
        goto <bb 7>; [66.00%]

      <bb 6> [local count: 79512730]:

      <bb 7> [local count: 1073741824]:
      # prephitmp_7 = PHI <1(3), 1(4), 0(5), 1(2), 1(6)>
    (i.e. the true/false edges on the last bb with condition swapped
    and ditto for the phi args), we don't recognize it.  If bb 6
    is empty, there should be no functional difference between the two IL
    representations.

    This patch handles those special cases.

    2020-08-06  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/96480
            * tree-ssa-reassoc.c (suitable_cond_bb): Add TEST_SWAPPED_P
argument.
            If TEST_BB ends in cond and has one edge to *OTHER_BB and another
            through an empty bb to that block too, if PHI args don't match,
retry
            them through the other path from TEST_BB.
            (maybe_optimize_range_tests): Adjust callers.  Handle such LAST_BB
            through inversion of the condition.

            * gcc.dg/tree-ssa/pr96480.c: New test.

  parent reply	other threads:[~2020-08-06 13:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05  8:53 [Bug c++/96480] New: " kurkindmit at gmail dot com
2020-08-05 11:22 ` [Bug c++/96480] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
2020-08-05 11:26 ` jakub at gcc dot gnu.org
2020-08-05 11:32 ` [Bug tree-optimization/96480] " rguenth at gcc dot gnu.org
2020-08-05 11:44 ` jakub at gcc dot gnu.org
2020-08-05 14:29 ` jakub at gcc dot gnu.org
2020-08-06 13:48 ` cvs-commit at gcc dot gnu.org [this message]
2020-08-06 13:53 ` [Bug tree-optimization/96480] [8/9/10 " jakub at gcc dot gnu.org
2021-05-14  9:53 ` [Bug tree-optimization/96480] [9/10 " jakub at gcc dot gnu.org
2021-06-01  8:18 ` rguenth at gcc dot gnu.org
2022-05-27  9:43 ` [Bug tree-optimization/96480] [10 " rguenth at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
2023-07-07  9:01 ` rguenth 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-96480-4-xqchgAGiq4@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).