https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66660
--- Comment #6 from Andrey Belevantsev <abel at gcc dot gnu.org> --- I've debugged it on gcc-5.1.0 since the picture on trunk is different. Thanks Jakub for great explanations, it was not easy to get to the root problem. We speculate an insn (the load in your listing) but we do not make a check for it though we should. The thing that broke this was the fix for PR 45472. In that pr, we have moved a volatile insn too far up because we failed to merge the bits describing its volatility when we have processed a control flow split. The code to propagate the insn pattern with the insn merging was added when the volatility of the two insns from the both split branches differ. However, the volatility of the speculated insn and its original differ: the original insn may trap while the speculated version may not. Thus, we replace a speculative pattern with the original one per the PR 45472 fix for no reason. The attached patch for this problem just limits the original fix for pr 45472 to apply for non-speculative insns only. Jakub, can you check it on your code? The patch should apply to both gcc 5 and gcc 6, so you can use whichever is more convenient for you.