https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67778
--- Comment #14 from Segher Boessenkool <segher at gcc dot gnu.org> --- Author: segher Date: Fri Dec 11 00:27:14 2015 New Revision: 231552 URL: https://gcc.gnu.org/viewcvs?rev=231552&root=gcc&view=rev Log: Fix shrink-wrapping bug (PR67778, PR68634) After shrink-wrapping has found the "tightest fit" for where to place the prologue, it tries move it earlier (so that frame saves are run earlier) -- but without copying any more basic blocks. Unfortunately a candidate block we select can be inside a loop, and we will still allow it (because the loop always exits via our previously chosen block). We can do that just fine if we make a duplicate of the block, but we do not want to here. So we need to detect this situation. We can place the prologue at a previous block PRE only if PRE dominates every block reachable from it, because then we will never need to duplicate that block (it will always be executed with prologue). 2015-12-11 Segher Boessenkool <seg...@kernel.crashing.org> PR rtl-optimization/67778 PR rtl-optimization/68634 * shrink-wrap.c (try_shrink_wrapping): Add a comment about why we want to put the prologue earlier. When determining if an earlier block is suitable, make sure it dominates every block reachable from it. Modified: trunk/gcc/ChangeLog trunk/gcc/shrink-wrap.c