https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65765
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 35316 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35316&action=edit gcc5-pr65765.patch Untested fix. The main bug has been a return true; for GIMPLE_NOP/GIMPLE_PREDICT, that means compare_bb ignored anything in the rest of the basic block, which is obviously completely wrong. While looking at it, I think we should compare for GIMPLE_PREDICT the predictor/outcome, if somebody puts an effort to mark something as hot or cold, unifying it if they differ sounds wrong to me. And similarly, IMHO for GIMPLE_EH_DISPATCH we should compare the region number.