This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/59521] __builtin_expect not effective in switch
- From: "drepper.fsp at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Jul 2017 13:58:57 +0000
- Subject: [Bug middle-end/59521] __builtin_expect not effective in switch
- Auto-submitted: auto-generated
- References: <bug-59521-4@http.gcc.gnu.org/bugzilla/>
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?