From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AE1A8385782C; Tue, 20 Oct 2020 13:51:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE1A8385782C 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:51:18 +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:51:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97445 --- Comment #40 from Christophe Leroy = --- (In reply to Jakub Jelinek from comment #39) > (In reply to Christophe Leroy from comment #38) > > But on powerpc that's already the case and it doesn't solve the issue. > >=20 > > static inline int fls(unsigned int x) > > { > > return 32 - __builtin_clz(x); > > } > >=20 > > static inline int fls64(__u64 x) > > { > > return 64 - __builtin_clzll(x); > > } >=20 > That is clearly a kernel bug (__builtin_clz* is documented undefined for = 0, > while fls* wants to be well defined there), and shouldn't change anything, > because > in the if (__builtin_constant_p (size)) > case get_order doesn't use fls*, but ilog2. And it is ilog2 that should = be > changed. What's the bug ? int f(int x) { return __builtin_clz(x); } Compiles into : cntlzw r3, r3 blr Powerpc 32 bits documentation says: cntlzw : Count Leading Zeros Word A count of the number of consecutive zero bits starting at bit 0 of rS is placed into rA. This number ranges from 0 to 32, inclusive. I can't see a problem when x =3D=3D 0=