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/114215] GCC makes wrong decision for inline with -Os or -Oz to deal with trivial functions
Date: Sun, 03 Mar 2024 03:18:33 +0000	[thread overview]
Message-ID: <bug-114215-4-3VIPIcBMPe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114215-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2024-03-03

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
    checkedvector::value_type& checkedvector::operator[](size_type)/167 call is
unlikely and code size would grow
      freq:1.00 loop depth: 0 size: 4 time: 13 callee size: 6 stack: 0
       op1 is compile time invariant



If I had:
```
void test_demovector(checkedvector& vec, int x) noexcept
{
  for(int i = 0; i < y; i++)
    vec[i]=5;
}
```

Then GCC will inling operator[]:
    checkedvector::value_type& checkedvector::operator[](size_type)/167 inlined
      freq:8.09
      Stack frame offset 0, callee self size 0
      void __builtin_trap()/205 function body not available
        freq:0.00 loop depth: 1 size: 1 time:  1

I am suspecting this is the right heurstic. Do you have real code where the
inlining does not happen at -Os/-Oz or you just looking at the code generation
with code that might be benchmarking things?

  parent reply	other threads:[~2024-03-03  3:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03  2:53 [Bug rtl-optimization/114215] New: " unlvsur at live dot com
2024-03-03  3:06 ` [Bug ipa/114215] " pinskia at gcc dot gnu.org
2024-03-03  3:18 ` pinskia at gcc dot gnu.org [this message]
2024-03-03  3:27 ` unlvsur at live dot com
2024-03-03  3:30 ` unlvsur at live dot com
2024-03-03  3:36 ` pinskia at gcc dot gnu.org
2024-03-03  3:44 ` [Bug ipa/114215] -Os or -Oz inlining seems wrong for vague linkage functions unlvsur at live dot com
2024-03-03  3:45 ` unlvsur at live dot com
2024-03-06  2:23 ` unlvsur at live dot com

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-114215-4-3VIPIcBMPe@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).