From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E49053858414; Sun, 3 Mar 2024 03:18:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E49053858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709435913; bh=QvT0cWoo+hfDusogfQVSe04bqS3ex66QP/Y30bRSFxI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YSjW/uTWIgLqqJlI4eex39NuBwl8paZiOqrhQd9HNOfIOctjK23rOQhB1J6RwDn0I rMkzULOEspF3/QGgLzvIEY75yhsMDTzBDlcrR7b/iUWAgytdXcs9Q+hd8YkHbY55Ut j42TwhyjLi5OOj41ylGnilKS06dLPXwK8F9T8o0o= From: "pinskia at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed bug_status cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114215 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |WAITING Last reconfirmed| |2024-03-03 --- Comment #2 from Andrew Pinski --- checkedvector::value_type& checkedvector::operator[](size_type)/167 cal= l 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 =3D 0; i < y; i++) vec[i]=3D5; } ``` Then GCC will inling operator[]: checkedvector::value_type& checkedvector::operator[](size_type)/167 inl= ined 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 generat= ion with code that might be benchmarking things?=