https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66584
Jason McG <jmcguiness at liquidcapital dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- --- Comment #5 from Jason McG <jmcguiness at liquidcapital dot com> --- (In reply to Andrew Pinski from comment #3) > More than that, documenting gcc's branch heuristics is just in the code. And ... I am sorry, but I do not agree. As per my other reply, in comment 4, I think it is entirely reasonable to request that an additional statement along the lines of "code generation for switch statements may not follow a top-down approach nor prefer the default case (if it exists) in terms of static branch-prediction. The __builtin_expected() intrinsic has no effect" is included in the web-based documentation in a suitable sub-section. If some algorithm were used, then adding a link to the web site to the appropriate paper might be a quick remedy? This would ensure that developers are not mislead by the argument that __builtin_expected() takes thinking they could use that, nor would they be mislead by lore assuming that the default or a lexographic top-down approach to static branch-prediction were used.