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 ipa/103875] Dead writes are not optimized out
Date: Fri, 31 Dec 2021 14:14:41 +0000	[thread overview]
Message-ID: <bug-103875-4-Bqsnt1IPLR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103875-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
          Component|middle-end                  |ipa
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-12-31
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The inliner removes the clobber in this case it seems:
We have:

void foo::pop (struct foo * const this)
{
  long unsigned int _1;
  long unsigned int _2;
  long unsigned int _3;
  value_type * _4;

  <bb 2> :
  _1 = this_6(D)->size;
  _2 = _1 + 18446744073709551615;
  this_6(D)->size = _2;
  _3 = this_6(D)->size;
  _4 = &this_6(D)->data[_3];
  *_4 ={v} {CLOBBER};
  return;

}
void use_foo (struct foo & f)
{
  int _1;
  int _2;
  value_type & _6;

  <bb 2> :
  _6 = foo::back (f_4(D));
  _1 = *_6;
  _2 = _1 * 42;
  *_6 = _2;
  foo::pop (f_4(D));
  return;

}

And then foo::pop (and back) gets inlined we get:

void use_foo (struct foo & f)
{
  value_type & D.2143;
  int _1;
  int _2;
  long unsigned int _5;
  value_type & _6;
  long unsigned int _9;
  long unsigned int _10;
  long unsigned int _11;
  value_type & _12;
  value_type & _13;

  <bb 2> :
  _10 = f_4(D)->size;
  _11 = _10 + 18446744073709551615;
  _12 = &f_4(D)->data[_11];
  _13 = _12;
  _6 = _13;
  _1 = *_6;
  _2 = _1 * 42;
  *_6 = _2;
  _5 = f_4(D)->size;
  _9 = _5 + 18446744073709551615;
  f_4(D)->size = _9;
  return;

}

  reply	other threads:[~2021-12-31 14:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 13:08 [Bug pending/103875] New: " lh_mouse at 126 dot com
2021-12-31 14:14 ` pinskia at gcc dot gnu.org [this message]
2022-01-04 14:09 ` [Bug ipa/103875] " 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-103875-4-Bqsnt1IPLR@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).