public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences)
Date: Tue, 11 Jan 2022 10:54:44 +0000	[thread overview]
Message-ID: <bug-100220-4-9bypN4a4zF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100220-4@http.gcc.gnu.org/bugzilla/>

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |100314

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Here the stack frame size of i is stimated to 244 bytes
void i ()
{
  int p[8];
  int n[27];
  int k[24];
  int l;
  int j;
  int _1;
  int _2;
  int _3;
  int c.2_4;
  int _5;

  <bb 2> [local count: 236223200]:
  l = 0;
  k = {};
  h = &n;
  _1 = n[0];
  _2 = _1 & 1;
  if (_2 != 0)
    goto <bb 8>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 8> [local count: 118111600]:
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 955630225]:
  _3 = c.2_4 + -1;
  c = _3;

  <bb 4> [local count: 1073741824]:
  c.2_4 = c;
  if (c.2_4 != 0)
    goto <bb 3>; [89.00%]
  else
    goto <bb 5>; [11.00%]

  <bb 5> [local count: 236223200]:
  h = &p;
  _5 = p[0];
  if (_5 != 0)
    goto <bb 6>; [50.00%]
  else
    goto <bb 7>; [50.00%]

  <bb 6> [local count: 118111600]:
  h = &j;

  <bb 7> [local count: 236223200]:
  e = 0;
  j ={v} {CLOBBER};
  l ={v} {CLOBBER};
  k ={v} {CLOBBER};
  n ={v} {CLOBBER};
  p ={v} {CLOBBER};
  return;

}

so it indeed has larger arrays. k is initialized but never used (so it is
missed DSE). n is used in stupid way:

  h = &n;                                                                       
  _1 = n[0];                                                                    

where h is write only static var, but we do not know that during early opts (we
could try our luck and schedule one extra writeonly detection before early
optimization passes, but I am not sure it is worth).

I would say that main issue is also missed DSE


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100314
[Bug 100314] missed optimization for dead code elimination at -O3 (vs. -O1) 
(inlining differences due to missed dse)

  parent reply	other threads:[~2022-01-11 10:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
2021-09-25  9:49 ` [Bug ipa/100220] " pinskia at gcc dot gnu.org
2022-01-11  9:57 ` [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences) rguenth at gcc dot gnu.org
2022-01-11 10:54 ` hubicka at gcc dot gnu.org [this message]
2023-08-18  2:30 ` pinskia at gcc dot gnu.org
2024-05-16  9:05 ` 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-100220-4-9bypN4a4zF@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).