http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47028
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-30 13:19:21 UTC --- The problem is much earlier than that. In *.expand we have: ;; Start of basic block ( 0) -> 2 ;; Pred edge ENTRY [100.0%] (fallthru) (note 12 6 9 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn 9 12 7 2 (set (reg/v:SI 70 [ n ]) (reg/v:SI 72 [ n ])) pr47028.c:7 -1 (nil)) (insn 7 9 8 2 (set (reg/v:SI 72 [ n ]) (reg:SI 5 di [ n ])) pr47028.c:7 -1 (nil)) where obviously insn 7 should be before insn 9, not the other way around. The reason it is emitted that way is because in *.optimized we have: <bb 2>: # n_13 = PHI <n_3(D)(0)> and insn 9 is insert_partition_copy_on_edge'ed on the ENTRY_BLOCK_PTR -> bb 2 edge, which is before the argument setup. So, either insertions on the single edge from ENTRY_BLOCK_PTR to the entry bb should be committed after parm_birth_insn instead of the start of that bb, or we need to ensure even if the user ridiculously turns off all optimization passes that clean up degenerated PHIs they get cleaned up somewhere. The PHI here is created during tail recursion pass, but at that point it is not degenerate PHI, it only becomes one during some cfg cleanup afterwards.