https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120614
--- Comment #13 from Jan Hubicka <hubicka at ucw dot cz> --- > I re-tested and can confirm that it is working now. Sorry for the false alarm. I was fixing bug in this area recently, so perhaps you just had older tree. Should have mentioned that - sorry for that. I am happy the hack helps - I think this is probably the main problem of autoFDO right now. Current algorithm annotates the basic blocks with known counts and then uses kihroff law to compute counts of ther BBs. Extra logic tries to idenitfy blocks that must have same counts and propagate to them and also special case logcal circuits. Problem is that in many cases the optimized CFG we have data for is far aware form Cfg to see, so we do not have exact info to fill in the gaps. (A case I looked into was fully unroled loop that killed all count info on the loop conditional, for example). Keeping those counts 0 in these cases is wrong, since rest of optimizer will see it as BB not executing very often. We have undefined counts which can work better, but we ought to use static profile to help filling in the gaps. I need to think a bit about how involved we want to get here. For example we can use known trip counts of loops to be fully unrolled...