https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77445
--- Comment #19 from Jan Hubicka <hubicka at gcc dot gnu.org> --- One change that would make sense to me is to always thread when there is a non-cold block on the path: we are not only improving the path taken when threading but because we eliminate incoming edges we also permit better optimization of non-thread path later. This way we thread the branch, because there is still non-cold BB on a way. On related note, I have noticed that we give up on about 30% of jump threads in early optimization because of: /* Skip edges pointing outside the current loop. */ if (!arg || var_bb->loop_father != bbi->loop_father) continue; This is very common case such as in: char *c; int t() { for (int i=0;i<5000;i++) c[i]=i; } before loop header copying there is threadable branch at first iteration. Threading it before profile construction would be quite desirable. There seem to be code deciding on loops when checking path profitability. It seems to me that at least the code can be adjusted to accept thread starting by loop header when there is only single edge in becausee that can't make irreducible loops? Honza