public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109945] Escape analysis hates copy elision: different result with -O1 vs -O2
Date: Tue, 23 May 2023 16:09:45 +0000	[thread overview]
Message-ID: <bug-109945-4-7qlPKRtdDT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109945-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |tree-optimization
   Last reconfirmed|                            |2023-05-23
                 CC|                            |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
            Version|unknown                     |14.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
ESCAPED, points-to vars: { }

intD.9 mainD.2827 ()
{
  intD.9 w$iD.2845;
  intD.9 iD.2831;
  struct WidgetD.2773 wD.2829;
  intD.9 _1; 
  boolD.2740 _2;
  intD.9 _7; 

  <bb 2> :
  # USE = nonlocal  
  # CLB = nonlocal escaped
  wD.2829 = makeD.2813 (); [return slot optimization]
  w$i_9 = wD.2829.iD.2778;
  i_5 = w$i_9;
  # USE = nonlocal escaped
  # CLB = nonlocal escaped
  gD.2825 ();
  _1 = w$i_9;
  _2 = _1 == i_5;
  _7 = (intD.9) _2;
  wD.2829 ={v} {CLOBBER(eol)};
  return _7;

}

so indeed GCC points-to doesn't consider

  wD.2829 = makeD.2813 (); [return slot optimization]

as escape point for the return.  We have

  /* And if we applied NRV the address of the return slot escapes as well.  */
  if (gimple_call_return_slot_opt_p (stmt)
      && gimple_call_lhs (stmt) != NULL_TREE
      && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt))))
    {

but in this case the type is not TREE_ADDRESSABLE.  I'm not sure why this
check is here.  Removing it fixes the issue.  A !is_gimple_reg (lhs)
check may be a substitute in case we can get stale return-slot-opt flags?

  reply	other threads:[~2023-05-23 16:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 14:00 [Bug c++/109945] New: " arthur.j.odwyer at gmail dot com
2023-05-23 16:09 ` rguenth at gcc dot gnu.org [this message]
2023-05-23 16:11 ` [Bug tree-optimization/109945] " rguenth at gcc dot gnu.org
2023-05-23 16:19 ` pinskia at gcc dot gnu.org
2023-05-23 16:48 ` rguenth at gcc dot gnu.org
2023-05-23 16:53 ` rguenth at gcc dot gnu.org
2023-05-23 16:53 ` pinskia at gcc dot gnu.org
2023-05-23 17:46 ` arthur.j.odwyer at gmail dot com
2023-05-23 17:49 ` pinskia at gcc dot gnu.org
2023-05-23 17:52 ` pinskia at gcc dot gnu.org
2023-05-23 17:53 ` pinskia at gcc dot gnu.org
2023-05-23 19:38 ` arthur.j.odwyer at gmail dot com
2023-05-24  6:48 ` rguenth at gcc dot gnu.org
2023-05-24  7:59 ` rguenth at gcc dot gnu.org
2023-05-24  8:16 ` jakub at gcc dot gnu.org
2023-05-24  8:42 ` rguenther at suse dot de
2023-05-24  8:51 ` jakub at gcc dot gnu.org
2023-05-24  8:55 ` rguenther at suse dot de
2023-05-24  9:00 ` jakub at gcc dot gnu.org
2023-05-24 10:12 ` rguenth at gcc dot gnu.org
2023-07-01 23:37 ` pinskia at gcc dot gnu.org
2023-07-10  8:52 ` rguenth at gcc dot gnu.org
2024-02-20  9:58 ` rguenth at gcc dot gnu.org
2024-02-20 10:45 ` jakub at gcc dot gnu.org
2024-02-20 11:53 ` jakub at gcc dot gnu.org
2024-02-20 12:07 ` redi at gcc dot gnu.org
2024-02-20 12:15 ` redi at gcc dot gnu.org
2024-02-20 12:33 ` rguenth at gcc dot gnu.org
2024-02-20 12:41 ` redi at gcc dot gnu.org
2024-02-20 12:48 ` jakub at gcc dot gnu.org
2024-02-20 15:47 ` arthur.j.odwyer at gmail dot com
2024-02-20 15:52 ` arthur.j.odwyer at gmail dot com
2024-02-20 16:49 ` redi at gcc dot gnu.org
2024-03-01 17:20 ` redi 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-109945-4-7qlPKRtdDT@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).