Skip to content

Commit 6e04cec

Browse files
committed
[MISched] Compare right next cluster node
We support bottom-up and bidirectonal postra scheduling now, but we only compare successive next cluster node as if we are doing topdown scheduling. This makes load/store clustering and macro fusions wrong. This patch makes sure that we can get the right cluster node by the scheduling direction.
1 parent 9730760 commit 6e04cec

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,9 +3958,12 @@ bool PostGenericScheduler::tryCandidate(SchedCandidate &Cand,
39583958
return TryCand.Reason != NoCand;
39593959

39603960
// Keep clustered nodes together.
3961-
if (tryGreater(TryCand.SU == DAG->getNextClusterSucc(),
3962-
Cand.SU == DAG->getNextClusterSucc(),
3963-
TryCand, Cand, Cluster))
3961+
const SUnit *CandNextClusterSU =
3962+
Cand.AtTop ? DAG->getNextClusterSucc() : DAG->getNextClusterPred();
3963+
const SUnit *TryCandNextClusterSU =
3964+
TryCand.AtTop ? DAG->getNextClusterSucc() : DAG->getNextClusterPred();
3965+
if (tryGreater(TryCand.SU == TryCandNextClusterSU,
3966+
Cand.SU == CandNextClusterSU, TryCand, Cand, Cluster))
39643967
return TryCand.Reason != NoCand;
39653968

39663969
// Avoid critical resource consumption and balance the schedule.

llvm/test/CodeGen/RISCV/macro-fusion-lui-addi.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ define void @foo(i32 signext %0, i32 signext %1) {
4747
; FUSION-POSTRA-BIDIRECTIONAL-LABEL: foo:
4848
; FUSION-POSTRA-BIDIRECTIONAL: # %bb.0:
4949
; FUSION-POSTRA-BIDIRECTIONAL-NEXT: lui a0, %hi(.L.str)
50-
; FUSION-POSTRA-BIDIRECTIONAL-NEXT: fcvt.s.w fa0, a1
5150
; FUSION-POSTRA-BIDIRECTIONAL-NEXT: addi a0, a0, %lo(.L.str)
51+
; FUSION-POSTRA-BIDIRECTIONAL-NEXT: fcvt.s.w fa0, a1
5252
; FUSION-POSTRA-BIDIRECTIONAL-NEXT: tail bar
5353
%3 = sitofp i32 %1 to float
5454
tail call void @bar(ptr @.str, float %3)

0 commit comments

Comments
 (0)