From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 626053850415; Tue, 20 Oct 2020 13:28:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 626053850415 From: "christophe.leroy at csgroup dot eu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/97445] Some fonctions marked static inline in Linux kernel are not inlined Date: Tue, 20 Oct 2020 13:28:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: christophe.leroy at csgroup dot eu X-Bugzilla-Status: NEW 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 13:28:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97445 --- Comment #38 from Christophe Leroy = --- (In reply to Jan Hubicka from comment #32) > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97445 > >=20 > > --- Comment #31 from Segher Boessenkool --- > > (In reply to Jan Hubicka from comment #27) > > > It is because --param inline-insns-single was reduced for -O2 from 200 > > > to 70. GCC 10 has newly different set of parameters for -O2 and -O3 = and > > > enables auto-inlining at -O2. > > >=20 > > > Problem with inlininig funtions declared inline is that C++ codebases > > > tends to abuse this keyword for things that are really too large (and > > > get_order would be such example if it did not have builtin_constant_p > > > check which inliner does not understand well). So having same limit at > > > -O2 and -O3 turned out to be problematic with respect to code size and > > > especially with respect to LTO, where a lot more inlining oppurtuniti= es > > > appear. > >=20 > > Do the heuristics account for that not inlining a "static inline" resul= ts > > in multiple copies? >=20 > It prevents inlining only when there are multiple calls in the unit > being compiled (there is no way to know that the same inline function is > duplicated in other units). > This is what happens here: there are multiple calls so inliner concludes > inlining would cost too much of code size and later they are optimized > away. >=20 > get_order is a wrapper around ffs64. This can be implemented w/o asm > statement as follows: > int > my_fls64 (__u64 x) > { > if (!x) > return 0; > return 64 - __builtin_clzl (x); > } >=20 > This results in longer assembly than the kernel asm implementation. If > that matters I would replace builtin_constnat_p part of get_order by this > implementation that is more transparent to the code size estimation and > things will get inlined. >=20 But on powerpc that's already the case and it doesn't solve the issue. static inline int fls(unsigned int x) { return 32 - __builtin_clz(x); } static inline int fls64(__u64 x) { return 64 - __builtin_clzll(x); }=