https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63384
--- Comment #4 from Andi Kleen <andi-gcc at firstfloor dot org> --- It loops forever in this loop in sel_sched_region_2 while (fences) { int min_seqno, max_seqno; ilist_t scheduled_insns = NULL; ilist_t *scheduled_insns_tailp = &scheduled_insns; find_min_max_seqno (fences, &min_seqno, &max_seqno); schedule_on_fences (fences, max_seqno, &scheduled_insns_tailp); fences = calculate_new_fences (fences, orig_max_seqno, &max_time); highest_seqno_in_use = update_seqnos_and_stage (min_seqno, max_seqno, highest_seqno_in_use, &scheduled_insns); } because calculate_new_fences always comes up with a list which is the same as before. In move_fence_to_fences it always goes into the else f = flist_lookup (FLIST_TAIL_HEAD (new_fences), FENCE_INSN (FLIST_FENCE (old_fences))); if (f) { merge_fences (f, old->insn, old->state, old->dc, old->tc, old->last_scheduled_insn, old->executing_insns, old->ready_ticks, old->ready_ticks_size, old->sched_next, old->cycle, old->issue_more, old->after_stall_p); } else { _list_add (tailp); FLIST_TAIL_TAILP (new_fences) = &FLIST_NEXT (*tailp); So something is going wrong in flist_lookup.