This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/59521] __builtin_expect not effective in switch


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59521

--- Comment #12 from Ulrich Drepper <drepper.fsp at gmail dot com> ---
On Fri, Jul 14, 2017 at 2:17 PM, marxin at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> Maybe I miss something, but I would expect to sort all branches in
> emit_case_decision_tree as either predictors can sort branches, or one have a
> profile feedback. Having a chain of equal comparisons, that should be always
> beneficial, or?

I agree.  There seems to be no negative effect.  If you use a stable
sort algorithm the programmer can have influence when needed since the
program's order is preserved.  If the compiler has probability
information it should use it.  Note, I just mean the order of the
tests.  Deciding about placing code in cold sections is a different
story but this isn't what we're talking about here, right?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]