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-bugzi...@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?