https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85740
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Target| |x86_64-*-*, i?86-*-* Status|UNCONFIRMED |NEW Last reconfirmed| |2018-05-11 CC| |hubicka at gcc dot gnu.org, | |marxin at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed with a Haswell CPU as well. Without the __builtin_expect we rightfully predict the branch to be 50%/50% which means BB re-ordering will do either nothing to pre-existing order or apply some other magic. CFG construction makes the flow exactly as visible in the source. So not sure what you are asking here, but annotating the libgfortran routines or inline expansion from the FE with __builtin_expect is probably a good idea. At least I can't really see how to easily derive a new predictor that would match this case...