"extern inline" inlining heuristics in unlikely branches

2024-07-31 Thread Ilija Tovilo via Gcc
Hi everyone

I'm new here. I read the mailing list policy, but please correct me if
I'm doing anything wrong.

In our C codebase, we're using a fair amount of static inline
__attribute__((always_inline)). This is arguably not a great decision,
because it forces inlining under questionable conditions, i.e. in cold
functions and unlikely branches. We're looking into switching some
non-trivial functions to extern inline instead.

When testing I noticed that GCC avoids inlining in
__attribute__((cold)) functions, but not in unlikely branches, as
signaled by __builtin_expect(cond, 0), even if the caller is hot. See
https://godbolt.org/z/sxnYh5PsE. The unlikely branch is moved to the
bottom, but it still seems beneficial to avoid inlining to reduce
instruction cache pressure for the rest of the hot functions. I wasn't
able to achieve this behavior with __builtin_expect or
__builtin_expect_with_probability with a very high probability.

Coincidentally, Clang does the exact opposite, inlining in cold
functions, but not in unlikely branches.

This is just one example, and I don't know anything about the
heuristics GCC uses to determine if some function is inlined. I wanted
to bring this up nonetheless to see if this situation may be improved.

I wasn't sure if this belongs in the bug tracker, let me know if I
should move it there instead.

Thank you.

Ilija


Re: Second GCC 14.2 Release Candidate available from gcc.gnu.org

2024-07-31 Thread William Seurer via Gcc

On 7/29/24 9:45 AM, Jakub Jelinek via Gcc wrote:

The second release candidate for GCC 14.2 is available from

  https://gcc.gnu.org/pub/gcc/snapshots/14.2.0-RC-20240729/
  ftp://gcc.gnu.org/pub/gcc/snapshots/14.2.0-RC-20240729/

and shortly its mirrors.  It has been generated from git commit
r14-10521-gda7f0be91e2ae15.

I have so far bootstrapped and tested the release candidate on
x86_64-linux.
Please test it and report any issues to bugzilla.

If all goes well, we'd like to release 14.2 on Thursday, Aug 1st.


I bootstrapped and tested it on powerpc64 BE and LE on power 8, 9, and 
10 and all looked good.