public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/100686] New: attribute optimize ("O2") doesn't inline lambda
Date: Wed, 19 May 2021 17:20:08 +0000	[thread overview]
Message-ID: <bug-100686-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 100686
           Summary: attribute optimize ("O2") doesn't inline lambda
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Declaring with attribute optimize ("O2") a function that makes use of a trivial
lambda function with doesn't inline the lambda unless the whole translation
unit is compiled with optimization enabled.  I'm guessing this happens for the
same reason as pr100323, although here the problem seems more severe since the
lambda is defined fully in the scope of the called function.

$ cat t.C && gcc -S -Wall -fdump-tree-optimized=/dev/stdout t.C
__attribute__ ((optimize ("O2"))) int f ()
{
  return [](int x){ return x; }( 1 );
}


;; Function f()::<lambda(int)>::operator() (_ZZ1fvENKUliE_clEi, funcdef_no=1,
decl_uid=2352, cgraph_uid=1, symbol_order=0)

int f()::<lambda(int)>::operator() (const struct ._anon_0 * const __closure,
int x)
{
  <bb 2> [local count: 1073741824]:
  return x_1(D);

}



;; Function f (_Z1fv, funcdef_no=0, decl_uid=2346, cgraph_uid=4,
symbol_order=3)

__attribute__((optimize ("O2")))
int f ()
{
  struct ._anon_0 D.2371;
  int _2;

  <bb 2> [local count: 1073741824]:
  _2 = f()::<lambda(int)>::operator() (&D.2371, 1); [tail call]
  D.2371 ={v} {CLOBBER};
  return _2;

}

             reply	other threads:[~2021-05-19 17:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 17:20 msebor at gcc dot gnu.org [this message]
2021-05-20  6:40 ` [Bug c++/100686] " 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-100686-4@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).