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/103281] [9/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
Date: Tue, 16 Nov 2021 20:51:29 +0000	[thread overview]
Message-ID: <bug-103281-4-ggZex9EG5w@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103281-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
      Known to fail|                            |10.1.0, 12.0, 4.7.1, 4.8.1,
                   |                            |9.1.0
            Summary|[12 Regression] Dead Code   |[9/12 Regression] Dead Code
                   |Elimination Regression at   |Elimination Regression at
                   |-O3 (trunk vs 11.2.0)       |-O3 (trunk vs 11.2.0)
   Last reconfirmed|                            |2021-11-16
      Known to work|                            |11.1.0, 4.9.0, 4.9.4,
                   |                            |5.1.0, 6.1.0, 7.1.0, 8.1.0
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The only thing which PHIOPT does is change:
  if (c_15 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :

  <bb 5> :
  # iftmp.1_10 = PHI <0(4), c_15(3)>

to be:
iftmp.1_10 = c_15;

This is a missed VRP:
  # RANGE [0, 2] NONZERO 3
  c_9 = (charD.10) b.4_5;
  _1 = c_9 <= 0;
  # RANGE [0, 1] NONZERO 1
  _2 = (unsigned intD.14) _1;
  if (_2 == b.4_5)

_1/_2 is true/1 only when c_9 is 0 and only when b.4_5 is 0.

----- CUT -----


We should be able to optimize:
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    char c = b;
    char a = c;
    if (!((a < 1) ^ b))
      foo();
  }
}
Too.

We also miss:
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    if (!((b < 1) ^ b))
      foo();
  }
}

  _1 = b.2_6 == 0;
  _2 = (unsigned int) _1;
  if (_2 == b.2_6)

I want to say we should defer this until after GCC 12 because this was only
being optimized on accident.  phiopt1

  reply	other threads:[~2021-11-16 20:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 " theodort at inf dot ethz.ch
2021-11-16 20:51 ` pinskia at gcc dot gnu.org [this message]
2021-11-16 20:52 ` [Bug tree-optimization/103281] [9/10/12 " pinskia at gcc dot gnu.org
2021-11-16 21:03 ` pinskia at gcc dot gnu.org
2021-11-16 21:16 ` pinskia at gcc dot gnu.org
2021-11-18 10:31 ` marxin at gcc dot gnu.org
2022-01-18 14:28 ` rguenth at gcc dot gnu.org
2022-05-27  9:46 ` [Bug tree-optimization/103281] [10/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-05-01 23:49 ` [Bug tree-optimization/103281] [10/12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  5:47 ` [Bug tree-optimization/103281] [12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
2023-08-08 15:43 ` pinskia at gcc dot gnu.org
2023-08-08 15:46 ` 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-103281-4-ggZex9EG5w@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).