[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using __builtin_expect (likely/unlikely macros)
From: |
Stefan Monnier |
Subject: |
Re: Using __builtin_expect (likely/unlikely macros) |
Date: |
Tue, 16 Apr 2019 09:05:22 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>>> These macro calls would not help near calls to emacs_abort, as it
>>> should already be obvious to a careful human reader that the jump to
>>> emacs_abort is the road less traveled. (That's also obvious to GCC,
>>> since emacs_abort is _Noreturn.)
>> To human readers, yes, but from what I can tell, GCC is mixed on this.
> Then we should fix GCC, if the code it generates has a performance problem
> (whatever it is, it's quite small).
FWIW, the fact that a function is "_Noreturn" doesn't necessarily mean
that a call to it is unlikely (in many cases it is, I guess, but
definitely not all), so maybe GCC maintainers consciously decided not to
link the two.
> The GCC manual recommends against manually inserting such calls;
It's likely based on some past experiments that showed programmers
aren't very good at understanding what is likely and what isn't in
their code.
BTW I think instead of marking branches as likely or unlikely, I'd
prefer to tell GCC that some functions "should be slow"
(e.g. emacs_abort) so it optimizes the code paths that don't go through
those functions to the detriment of those that do.
Stefan
- Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/14
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/14
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/14
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Eli Zaretskii, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Eli Zaretskii, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/15
- Re: Using __builtin_expect (likely/unlikely macros),
Stefan Monnier <=
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Alex Gramiak, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Stefan Monnier, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Konstantin Kharlamov, 2019/04/16
- Re: Using __builtin_expect (likely/unlikely macros), Paul Eggert, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Konstantin Kharlamov, 2019/04/18
- Re: Using __builtin_expect (likely/unlikely macros), Andy Moreton, 2019/04/18