diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 7da9b3a9c2765..1722bdda99e4a 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -3958,9 +3958,12 @@ bool PostGenericScheduler::tryCandidate(SchedCandidate &Cand, return TryCand.Reason != NoCand; // Keep clustered nodes together. - if (tryGreater(TryCand.SU == DAG->getNextClusterSucc(), - Cand.SU == DAG->getNextClusterSucc(), - TryCand, Cand, Cluster)) + const SUnit *CandNextClusterSU = + Cand.AtTop ? DAG->getNextClusterSucc() : DAG->getNextClusterPred(); + const SUnit *TryCandNextClusterSU = + TryCand.AtTop ? DAG->getNextClusterSucc() : DAG->getNextClusterPred(); + if (tryGreater(TryCand.SU == TryCandNextClusterSU, + Cand.SU == CandNextClusterSU, TryCand, Cand, Cluster)) return TryCand.Reason != NoCand; // Avoid critical resource consumption and balance the schedule. diff --git a/llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll b/llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll index 861297ca95337..3f758e25c4217 100644 --- a/llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll +++ b/llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll @@ -47,8 +47,8 @@ define void @foo(i32 signext %0, i32 signext %1) { ; FUSION-POSTRA-BIDIRECTIONAL-LABEL: foo: ; FUSION-POSTRA-BIDIRECTIONAL: # %bb.0: ; FUSION-POSTRA-BIDIRECTIONAL-NEXT: lui a0, %hi(.L.str) -; FUSION-POSTRA-BIDIRECTIONAL-NEXT: fcvt.s.w fa0, a1 ; FUSION-POSTRA-BIDIRECTIONAL-NEXT: addi a0, a0, %lo(.L.str) +; FUSION-POSTRA-BIDIRECTIONAL-NEXT: fcvt.s.w fa0, a1 ; FUSION-POSTRA-BIDIRECTIONAL-NEXT: tail bar %3 = sitofp i32 %1 to float tail call void @bar(ptr @.str, float %3)