diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index f79b39140c0..ef916174267 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -2492,7 +2492,10 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand, return; // For loops that are acyclic path limited, aggressively schedule for latency. - if (Rem.IsAcyclicLatencyLimited && tryLatency(TryCand, Cand, Zone)) + // This can result in very long dependence chains scheduled in sequence, so + // once every cycle (when CurrMOps == 0), switch to normal heuristics. + if (Rem.IsAcyclicLatencyLimited && !Zone.CurrMOps + && tryLatency(TryCand, Cand, Zone)) return; // Keep clustered nodes together to encourage downstream peephole